Commit 80671333 authored by Jason Madden's avatar Jason Madden Committed by GitHub

Merge pull request #1429 from vstinner/code_replace

Use CodeType.replace() if available
parents edf0ac17 1b84da94
......@@ -198,7 +198,11 @@ class Traceback(object):
while current:
f_code = current.tb_frame.f_code
code = compile('\n' * (current.tb_lineno - 1) + 'raise __traceback_maker', current.tb_frame.f_code.co_filename, 'exec')
if PY3:
if hasattr(code, "replace"):
# Python 3.8 and newer
code = code.replace(co_argcount=0,
co_freevars=(), co_cellvars=())
elif PY3:
code = CodeType(
0, code.co_kwonlyargcount,
code.co_nlocals, code.co_stacksize, code.co_flags,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment