Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove column table from code objects.
  • Loading branch information
markshannon committed Apr 14, 2022
commit 34ec9d9fc3b3fadb4e750715fad8d10a69475de3
6 changes: 2 additions & 4 deletions Include/cpython/code.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ typedef uint16_t _Py_CODEUNIT;
PyObject *co_endlinetable; /* bytes object that holds end lineno for \
instructions separated across different \
lines */ \
PyObject *co_columntable; /* bytes object that holds start/end column \
offset each instruction */ \
\
PyObject *co_locationtable; /* bytes object that holds location info */ \
PyObject *co_weakreflist; /* to support weakrefs to code objects */ \
Expand Down Expand Up @@ -154,13 +152,13 @@ PyAPI_FUNC(PyCodeObject *) PyCode_New(
int, int, int, int, int, PyObject *, PyObject *,
PyObject *, PyObject *, PyObject *, PyObject *,
PyObject *, PyObject *, PyObject *, int, PyObject *,
PyObject *, PyObject *, PyObject *, PyObject *);
PyObject *, PyObject *, PyObject *);

PyAPI_FUNC(PyCodeObject *) PyCode_NewWithPosOnlyArgs(
int, int, int, int, int, int, PyObject *, PyObject *,
PyObject *, PyObject *, PyObject *, PyObject *,
PyObject *, PyObject *, PyObject *, int, PyObject *,
PyObject *, PyObject *, PyObject *, PyObject *);
PyObject *, PyObject *, PyObject *);
/* same as struct above */

/* Creates a new empty code object with the specified source location. */
Expand Down
1 change: 0 additions & 1 deletion Include/internal/pycore_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ struct _PyCodeConstructor {
int firstlineno;
PyObject *linetable;
PyObject *endlinetable;
PyObject *columntable;
PyObject *locationtable;

/* used by the code */
Expand Down
25 changes: 14 additions & 11 deletions Lib/test/test_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,8 @@ def func(): pass
co.co_firstlineno,
co.co_lnotab,
co.co_endlinetable,
co.co_columntable,
co.co_exceptiontable,
co.co_locationtable,
co.co_exceptiontable,
co.co_freevars,
co.co_cellvars)

Expand Down Expand Up @@ -275,7 +274,6 @@ def func2():
("co_name", "newname"),
("co_linetable", code2.co_linetable),
("co_endlinetable", code2.co_endlinetable),
("co_columntable", code2.co_columntable),
):
with self.subTest(attr=attr, value=value):
new_code = code.replace(**{attr: value})
Expand Down Expand Up @@ -314,9 +312,8 @@ def func():
co.co_firstlineno,
co.co_lnotab,
co.co_endlinetable,
co.co_columntable,
co.co_exceptiontable,
co.co_locationtable,
co.co_exceptiontable,
co.co_freevars,
co.co_cellvars,
)
Expand Down Expand Up @@ -393,14 +390,17 @@ def test_co_positions_artificial_instructions(self):
)

def test_endline_and_columntable_none_when_no_debug_ranges(self):
# Make sure that if `-X no_debug_ranges` is used, the endlinetable and
# columntable are None.
# Make sure that if `-X no_debug_ranges` is used, there is
# minimal debug info
code = textwrap.dedent("""
def f():
pass

assert f.__code__.co_endlinetable is None
assert f.__code__.co_columntable is None
positions = f.__code__.co_positions()
for line, end_line, column, end_column in positions:
assert line == end_line
assert column is None
assert end_column is None
""")
assert_python_ok('-X', 'no_debug_ranges', '-c', code)

Expand All @@ -410,8 +410,11 @@ def test_endline_and_columntable_none_when_no_debug_ranges_env(self):
def f():
pass

assert f.__code__.co_endlinetable is None
assert f.__code__.co_columntable is None
positions = f.__code__.co_positions()
for line, end_line, column, end_column in positions:
assert line == end_line
assert column is None
assert end_column is None
""")
assert_python_ok('-c', code, PYTHONNODEBUGRANGES='1')

Expand Down
68 changes: 29 additions & 39 deletions Objects/clinic/codeobject.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading