mirror of
				https://github.com/python/cpython.git
				synced 2025-10-25 18:54:53 +00:00 
			
		
		
		
	bpo-42246: Partial implementation of PEP 626. (GH-23113)
* Implement new line number table format, as defined in PEP 626.
This commit is contained in:
		
							parent
							
								
									cda99b4022
								
							
						
					
					
						commit
						877df851c3
					
				
					 19 changed files with 5364 additions and 5000 deletions
				
			
		|  | @ -648,19 +648,28 @@ def addr2line(self, addrq): | |||
|         Analogous to PyCode_Addr2Line; translated from pseudocode in | ||||
|         Objects/lnotab_notes.txt | ||||
|         ''' | ||||
|         co_lnotab = self.pyop_field('co_lnotab').proxyval(set()) | ||||
|         co_linetable = self.pyop_field('co_linetable').proxyval(set()) | ||||
| 
 | ||||
|         # Initialize lineno to co_firstlineno as per PyCode_Addr2Line | ||||
|         # not 0, as lnotab_notes.txt has it: | ||||
|         lineno = int_from_int(self.field('co_firstlineno')) | ||||
| 
 | ||||
|         if addrq < 0: | ||||
|             return lineno | ||||
|         addr = 0 | ||||
|         for addr_incr, line_incr in zip(co_lnotab[::2], co_lnotab[1::2]): | ||||
|         for addr_incr, line_incr in zip(co_linetable[::2], co_linetable[1::2]): | ||||
|             if addr_incr == 255: | ||||
|                 break | ||||
|             addr += ord(addr_incr) | ||||
|             line_delta = ord(line_incr) | ||||
|             if line_delta == 128: | ||||
|                 line_delta = 0 | ||||
|             elif line_delta > 128: | ||||
|                 line_delta -= 256 | ||||
|             lineno += line_delta | ||||
|             if addr > addrq: | ||||
|                 return lineno | ||||
|             lineno += ord(line_incr) | ||||
|         return lineno | ||||
|         assert False, "Unreachable" | ||||
| 
 | ||||
| 
 | ||||
| class PyDictObjectPtr(PyObjectPtr): | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Mark Shannon
						Mark Shannon