mirror of
				https://github.com/python/cpython.git
				synced 2025-11-01 06:01:29 +00:00 
			
		
		
		
	bpo-32176: Set CO_NOFREE in the code object constructor (GH-4675)
Previously, CO_NOFREE was set in the compiler, which meant it could end up being set incorrectly when code objects were created directly. Setting it in the constructor based on freevars and cellvars ensures it is always accurate, regardless of how the code object is defined.
This commit is contained in:
		
							parent
							
								
									7324b5ce8e
								
							
						
					
					
						commit
						078f1814f1
					
				
					 4 changed files with 59 additions and 6 deletions
				
			
		|  | @ -5273,11 +5273,6 @@ compute_code_flags(struct compiler *c) | |||
|     /* (Only) inherit compilerflags in PyCF_MASK */ | ||||
|     flags |= (c->c_flags->cf_flags & PyCF_MASK); | ||||
| 
 | ||||
|     if (!PyDict_GET_SIZE(c->u->u_freevars) && | ||||
|         !PyDict_GET_SIZE(c->u->u_cellvars)) { | ||||
|         flags |= CO_NOFREE; | ||||
|     } | ||||
| 
 | ||||
|     return flags; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Nick Coghlan
						Nick Coghlan