mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	gh-98608: Fix Failure-handling in new_interpreter() (gh-102658)
The error-handling code in new_interpreter() has been broken for a while. We hadn't noticed because those code mostly doesn't fail. (I noticed while working on gh-101660.) The problem is that we try to clear/delete the newly-created thread/interpreter using itself, which just failed. The solution is to switch back to the calling thread state first. https://github.com/python/cpython/issues/98608
This commit is contained in:
		
							parent
							
								
									0214c7ad90
								
							
						
					
					
						commit
						d1b883b52a
					
				
					 1 changed files with 1 additions and 1 deletions
				
			
		|  | @ -2062,10 +2062,10 @@ new_interpreter(PyThreadState **tstate_p, const _PyInterpreterConfig *config) | ||||||
| 
 | 
 | ||||||
|     /* Oops, it didn't work.  Undo it all. */ |     /* Oops, it didn't work.  Undo it all. */ | ||||||
|     PyErr_PrintEx(0); |     PyErr_PrintEx(0); | ||||||
|  |     PyThreadState_Swap(save_tstate); | ||||||
|     PyThreadState_Clear(tstate); |     PyThreadState_Clear(tstate); | ||||||
|     PyThreadState_Delete(tstate); |     PyThreadState_Delete(tstate); | ||||||
|     PyInterpreterState_Delete(interp); |     PyInterpreterState_Delete(interp); | ||||||
|     PyThreadState_Swap(save_tstate); |  | ||||||
| 
 | 
 | ||||||
|     return status; |     return status; | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Eric Snow
						Eric Snow