Skip to content
Merged
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
gh-89419: gdb: fix bug causing AttributeError in py-locals when no fr…
…ame is available (GH-100611)

```
Unable to read information on python frame
Python Exception <class 'AttributeError'>: 'NoneType' object has no attribute 'co_name'
```

Regression in commit b4903af. While
refactoring the code into a while loop, the previous early return when
no frame exists went missing. We have just printed a message that we
cannot get information about this, so the frame will be None, and we
cannot attempt to use it.

Discovered on python 3.11, in python 3.12a2 this should error out with
`.is_shim()` instead of `co_name`.

(cherry picked from commit 8586949)
  • Loading branch information
eli-schwartz committed Jan 4, 2023
commit d34b3ef84d26c4f0accba8095374f561c58c96a1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug that caused an :exc:`AttributeError` to be raised in ``python-gdb.py`` when ``py-locals`` is used without a frame.
1 change: 1 addition & 0 deletions Tools/gdb/libpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -2126,6 +2126,7 @@ def invoke(self, args, from_tty):
while True:
if not pyop_frame:
print(UNABLE_READ_INFO_PYTHON_FRAME)
break

sys.stdout.write('Locals for %s\n' % (pyop_frame.co_name.proxyval(set())))

Expand Down