diff options
Diffstat (limited to 'Lib/test/test_marshal.py')
| -rw-r--r-- | Lib/test/test_marshal.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/Lib/test/test_marshal.py b/Lib/test/test_marshal.py index 7bcf8e8..152301f 100644 --- a/Lib/test/test_marshal.py +++ b/Lib/test/test_marshal.py @@ -1,5 +1,6 @@ from test import support -from test.support import os_helper +from test.support import os_helper, requires_debug_ranges +from test.support.script_helper import assert_python_ok import array import io import marshal @@ -7,6 +8,7 @@ import sys import unittest import os import types +import textwrap try: import _testcapi @@ -126,6 +128,31 @@ class CodeTestCase(unittest.TestCase): self.assertEqual(co1.co_filename, "f1") self.assertEqual(co2.co_filename, "f2") + @requires_debug_ranges() + def test_no_columntable_and_endlinetable_with_no_debug_ranges(self): + # Make sure when demarshalling objects with `-X no_debug_ranges` + # that the columntable and endlinetable are None. + co = ExceptionTestCase.test_exceptions.__code__ + code = textwrap.dedent(""" + import sys + import marshal + with open(sys.argv[1], 'rb') as f: + co = marshal.load(f) + + assert co.co_endlinetable is None + assert co.co_columntable is None + """) + + try: + with open(os_helper.TESTFN, 'wb') as f: + marshal.dump(co, f) + + assert_python_ok('-X', 'no_debug_ranges', + '-c', code, os_helper.TESTFN, + __cleanenv=True) + finally: + os_helper.unlink(os_helper.TESTFN) + @support.cpython_only def test_same_filename_used(self): s = """def f(): pass\ndef g(): pass""" |
