Skip to content

gh-90810: Use code.co_qualname to provide richer information #31150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion Lib/test/test_asyncio/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -2245,7 +2245,7 @@ def check_source_traceback(h):
self.assertEqual(h._source_traceback[-1][:3],
(__file__,
lineno,
'test_handle_source_traceback'))
self.test_handle_source_traceback.__qualname__))

# call_soon
h = loop.call_soon(noop)
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_asyncio/test_futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ def test_future_source_traceback(self):
self.assertEqual(future._source_traceback[-2][:3],
(__file__,
lineno,
'test_future_source_traceback'))
self.test_future_source_traceback.__qualname__))

@mock.patch('asyncio.base_events.logger')
def check_future_exception_never_retrieved(self, debug, m_log):
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_asyncio/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2159,7 +2159,7 @@ def test_task_source_traceback(self):
self.assertEqual(task._source_traceback[-2][:3],
(__file__,
lineno,
'test_task_source_traceback'))
self.test_task_source_traceback.__qualname__))
self.loop.run_until_complete(task)

def _test_cancel_wait_for(self, timeout):
Expand Down
10 changes: 5 additions & 5 deletions Lib/test/test_faulthandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def __del__(self):
""",
9,
'Segmentation fault',
function='__del__',
function='RefCycle.__del__',
garbage_collecting=True)

def test_fatal_error_c_thread(self):
Expand Down Expand Up @@ -575,10 +575,10 @@ def run(self):
lineno = 10
regex = r"""
^Thread 0x[0-9a-f]+ \(most recent call first\):
(?: File ".*threading.py", line [0-9]+ in [_a-z]+
){{1,3}} File "<string>", line 23 in run
File ".*threading.py", line [0-9]+ in _bootstrap_inner
File ".*threading.py", line [0-9]+ in _bootstrap
(?: File ".*threading.py", line [0-9]+ in [._a-zA-Z]+
){{1,3}} File "<string>", line 23 in Waiter.run
File ".*threading.py", line [0-9]+ in Thread._bootstrap_inner
File ".*threading.py", line [0-9]+ in Thread._bootstrap

Current thread 0x[0-9a-f]+ \(most recent call first\):
File "<string>", line {lineno} in dump
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_pyexpat.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,11 @@ def test_exception(self):
entries = traceback.extract_tb(e.__traceback__)
self.assertEqual(len(entries), 3)
self.check_traceback_entry(entries[0],
"test_pyexpat.py", "test_exception")
"test_pyexpat.py", self.test_exception.__qualname__)
self.check_traceback_entry(entries[1],
"pyexpat.c", "StartElement")
self.check_traceback_entry(entries[2],
"test_pyexpat.py", "StartElementHandler")
"test_pyexpat.py", self.StartElementHandler.__qualname__)
if (sysconfig.is_python_build()
and not (sys.platform == 'win32' and platform.machine() == 'ARM')
and not is_emscripten
Expand Down
8 changes: 4 additions & 4 deletions Lib/test/test_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ def g456():
frame = d.pop(thread_id)
stack = traceback.extract_stack(frame)
for i, (filename, lineno, funcname, sourceline) in enumerate(stack):
if funcname == "f123":
if funcname == f123.__qualname__:
break
else:
self.fail("didn't find f123() on thread's call stack")
Expand All @@ -458,7 +458,7 @@ def g456():

# And the next record must be for g456().
filename, lineno, funcname, sourceline = stack[i+1]
self.assertEqual(funcname, "g456")
self.assertEqual(funcname, g456.__qualname__)
self.assertIn(sourceline, ["leave_g.wait()", "entered_g.set()"])

# Reap the spawned thread.
Expand Down Expand Up @@ -516,7 +516,7 @@ def g456():
exc_type, exc_value, exc_tb = d.pop(thread_id)
stack = traceback.extract_stack(exc_tb.tb_frame)
for i, (filename, lineno, funcname, sourceline) in enumerate(stack):
if funcname == "f123":
if funcname == f123.__qualname__:
break
else:
self.fail("didn't find f123() on thread's call stack")
Expand All @@ -525,7 +525,7 @@ def g456():

# And the next record must be for g456().
filename, lineno, funcname, sourceline = stack[i+1]
self.assertEqual(funcname, "g456")
self.assertEqual(funcname, g456.__qualname__)
self.assertTrue(sourceline.startswith("if leave_g.wait("))

# Reap the spawned thread.
Expand Down
8 changes: 4 additions & 4 deletions Lib/test/test_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,10 @@ def test_traced_decorated_function(self):

expected = {
self.filemod + ('traced_decorated_function',): 1,
self.filemod + ('decorator_fabric',): 1,
self.filemod + ('decorator2',): 1,
self.filemod + ('decorator1',): 1,
self.filemod + ('func',): 1,
self.filemod + ('traced_decorated_function.<locals>.decorator_fabric',): 1,
self.filemod + ('traced_decorated_function.<locals>.decorator_fabric.<locals>.decorator2',): 1,
self.filemod + ('traced_decorated_function.<locals>.decorator1',): 1,
self.filemod + ('traced_decorated_function.<locals>.func',): 1,
}
self.assertEqual(self.tracer.results().calledfuncs, expected)

Expand Down
Loading