Lines Matching refs:code
1 """This module includes tests of the code object representation.
20 consts: ('None', '<code object g>')
154 if r.startswith("<code object"):
155 yield "<code object %s>" % elt.co_name
160 """Print out a text representation of a code object."""
181 #Empty code object should raise, but not crash the VM
194 '''A new code object with a __class__ cell added to freevars'''
198 code = new_code(f.__code__)
202 setattr(cls, name, FunctionType(code, globals(), name, defaults, closure))
223 # test code constructor
253 code = func.__code__
268 ("co_flags", code.co_flags | inspect.CO_COROUTINE),
281 new_code = code.replace(**{attr: value})
284 new_code = code.replace(co_varnames=code2.co_varnames,
331 code = func.__code__
332 newcode = code.replace(co_name="func") # Should not raise SystemError
333 self.assertEqual(code, newcode)
338 new_code = code = func.__code__.replace(co_linetable=b'')
355 code = traceback.tb_frame.f_code
359 dis.get_instructions(code, show_caches=True),
360 code.co_positions(),
394 code = textwrap.dedent("""
404 assert_python_ok('-X', 'no_debug_ranges', '-c', code)
408 code = textwrap.dedent("""
418 assert_python_ok('-c', code, PYTHONNODEBUGRANGES='1')
508 # Create a code object in a clean environment so that we know we have
516 def callback(code):
519 # f is now the last reference to the function, and through it, the code
551 def parse_location_table(code):
552 line = code.co_firstlineno
553 it = iter(code.co_linetable)
559 code = (first_byte >> 3) & 15
561 if code == 15:
562 yield (code, length, None, None, None, None)
563 elif code == 14:
577 yield (code, length, line, end_line, col, end_col)
578 elif code == 13: # No column
581 yield (code, length, line, line, None, None)
582 elif code in (10, 11, 12): # new line
583 line_delta = code - 10
587 yield (code, length, line, line, column, end_column)
589 assert (0 <= code < 10)
591 column = code << 3 | (second_byte >> 4)
592 yield (code, length, line, line, column, column + (second_byte & 15))
594 def positions_from_location_table(code):
595 for _, length, line, end_line, col, end_col in parse_location_table(code):
736 # reference to the code object. We need the code objects to go
757 # when the code object is cleaned up.
782 # Freeing a code object on a different thread then