summaryrefslogtreecommitdiff
path: root/Lib/test/test_code.py
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2021-04-29 13:12:51 +0100
committerGitHub <noreply@github.com>2021-04-29 13:12:51 +0100
commitc76da79b37d2bcbe575cc927ba0a9b7a9ce465db (patch)
treecf5e884131b3f44f038355ff4980cfbb97a6e228 /Lib/test/test_code.py
parent53dd6c99b39d90935c00bc1558582e494641248e (diff)
downloadcpython-git-c76da79b37d2bcbe575cc927ba0a9b7a9ce465db.tar.gz
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.
Diffstat (limited to 'Lib/test/test_code.py')
-rw-r--r--Lib/test/test_code.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_code.py b/Lib/test/test_code.py
index 467e8e5e33..6aaf04ca6d 100644
--- a/Lib/test/test_code.py
+++ b/Lib/test/test_code.py
@@ -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])