aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_marshal.py
diff options
context:
space:
mode:
authorAmmar Askar <ammar@ammaraskar.com>2021-07-07 15:07:12 -0400
committerGitHub <noreply@github.com>2021-07-07 20:07:12 +0100
commit4823d9a51281ebbc8e8d82a0dd3edc7d13ea8ac7 (patch)
treeb7c97af7b1d15da75321e1434997163cd8c6b9d0 /Lib/test/test_marshal.py
parent3d3027c5fcc683c14ee55ad231d79971ba12b24d (diff)
downloadcpython-4823d9a51281ebbc8e8d82a0dd3edc7d13ea8ac7.tar.gz
cpython-4823d9a51281ebbc8e8d82a0dd3edc7d13ea8ac7.zip
bpo-43950: Add option to opt-out of PEP-657 (GH-27023)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com> Co-authored-by: Batuhan Taskaya <batuhanosmantaskaya@gmail.com> Co-authored-by: Ammar Askar <ammar@ammaraskar.com>
Diffstat (limited to 'Lib/test/test_marshal.py')
-rw-r--r--Lib/test/test_marshal.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/Lib/test/test_marshal.py b/Lib/test/test_marshal.py
index 7bcf8e8399a..152301f16a9 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"""