mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	gh-119180: Add LOAD_COMMON_CONSTANT opcode (#119321)
The PEP 649 implementation will require a way to load NotImplementedError from the bytecode. @markshannon suggested implementing this by converting LOAD_ASSERTION_ERROR into a more general mechanism for loading constants. This PR adds this new opcode. I will work on the rest of the implementation of the PEP separately. Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									506b1a3ff6
								
							
						
					
					
						commit
						98e855fcc1
					
				
					 22 changed files with 337 additions and 288 deletions
				
			
		|  | @ -1184,8 +1184,18 @@ dummy_func( | |||
|             } | ||||
|         } | ||||
| 
 | ||||
|         inst(LOAD_ASSERTION_ERROR, ( -- value)) { | ||||
|             value = Py_NewRef(PyExc_AssertionError); | ||||
|         inst(LOAD_COMMON_CONSTANT, ( -- value)) { | ||||
|             // Keep in sync with _common_constants in opcode.py
 | ||||
|             switch(oparg) { | ||||
|             case CONSTANT_ASSERTIONERROR: | ||||
|                 value = PyExc_AssertionError; | ||||
|                 break; | ||||
|             case CONSTANT_NOTIMPLEMENTEDERROR: | ||||
|                 value = PyExc_NotImplementedError; | ||||
|                 break; | ||||
|             default: | ||||
|                 Py_FatalError("bad LOAD_COMMON_CONSTANT oparg"); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         inst(LOAD_BUILD_CLASS, ( -- bc)) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Jelle Zijlstra
						Jelle Zijlstra