bpo-42739: Don't use sentinels to mark end of line table. (GH-25657)

* Add length parameter to PyLineTable_InitAddressRange and doen't use sentinel values at end of table. Makes the line number table more robust.

* Update PyCodeAddressRange to match PEP 626.
This commit is contained in:
Mark Shannon 2021-04-29 13:12:51 +01:00 committed by GitHub
parent 53dd6c99b3
commit c76da79b37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 4968 additions and 4986 deletions

View file

@ -264,6 +264,12 @@ class CodeTest(unittest.TestCase):
new_code = code.replace(**{attr: value})
self.assertEqual(getattr(new_code, attr), value)
def test_empty_linetable(self):
def func():
pass
new_code = code = func.__code__.replace(co_linetable=b'')
self.assertEqual(list(new_code.co_lines()), [])
def isinterned(s):
return s is sys.intern(('_' + s + '_')[1:-1])