gh-102114: Make dis print more concise tracebacks for syntax errors in str inputs by chgnrdv · Pull Request #102115 · python/cpython · GitHub
Skip to content
6 changes: 3 additions & 3 deletions Lib/dis.py
7 changes: 7 additions & 0 deletions Lib/test/test_dis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,13 @@ def check(expected, **kwargs):
check(dis_nested_2, depth=None)
check(dis_nested_2)

def test__try_compile_no_context_exc_on_error(self):
# see gh-102114
try:
dis._try_compile(")", "")
except Exception as e:
self.assertIsNone(e.__context__)

@staticmethod
def code_quicken(f, times=ADAPTIVE_WARMUP_DELAY):
for _ in range(times):
Expand Down