-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-29680: Older gdb does not have gdb.error. #363
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
Conversation
@abalkin, thanks for your PR! By analyzing the history of the files in this pull request, we identified @benjaminp, @loewis and @Haypo to be potential reviewers. |
@the-knights-who-say-ni - I don't see anythyng wrong with my b.p.o details: |
Tools/gdb/libpython.py
Outdated
try: | ||
_gdb_error = gdb.error | ||
except AttributeError: | ||
_gdb_error = RuntimeError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you move this to top of this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is currently at the PyDictObjectPtr class scope. I can move this to the top of the class unless you think it may be useful elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gdb.error seems inherits RuntimeError.
We can use just RuntimeError, maybe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. BTW, can you point me where gdb.error is defined? I cloned binutils-gdb, but could not find the right place. Nevertheless I can confirm the inheritance:
(gdb) python print gdb.error.mro()
[<class 'gdb.error'>, <type 'exceptions.RuntimeError'>, <type 'exceptions.StandardError'>, <type 'exceptions.Exception'>, <type 'exceptions.BaseException'>, <type 'object'>]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@methane: " We can use just RuntimeError, maybe."
I prefer to use gdb.error when available to not catch a real RuntimeError bug by mistake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK.
There are many except RuntimeError
in this file and most of them may be gdb.error
.
So let's make _gdb_error
global instead of class attribute for it can be used from other places in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nits) _gdb_error = getattr(gdb, 'error', RuntimeError)
is shorter than try~except.
@abalkin, somehow your change was committed under GitHub username |
@Mariatta - I can probably fix that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dislike this change. I would prefer to catch gdb.error if available, or fallback on RuntimeError. Something like:
try:
GDB_ERROR = gdb.error
except AttributeError:
# gdb.error was introduced in gdb X.3
GDB_ERROR = RuntimeError
...
except GDB_ERROR
gdb.error was introduced in gdb 7.3 by the commit 07ca107c2d958b45633ef0cdcce7219a95f0cf01:
I tried but failed to use Git to find the first release including the commit, so I downloaded tarballs and use dichotomy to find gdb 7.3 version ;-)
Please update also the commit message to mention that the change adds support for gdb 7.0-7.2.
No, you should use "needs backport to 3.6" label. The other label is for the cherry-pick PR ;-) |
http://bugs.python.org/user1427 is "Alexander Belopolsky" and has GitHub login "abalkin". @abalkin: are you Alexander Belopolsky? https://github.com/abalkin says "Lev Abalkin". I would prefer to see this identify issue fixed before merging the change. |
Note: Please don't replace RuntimeError with gdb.error: I looked at some .c file in gdb/python/, and it seems like RuntimeError is sometimes raised instead of gdb.error! |
@Haypo - I have a small preference for keeping this bug fix simple and just use RuntimeError as is done elsewhere in this file. If someone wants to switch to catching more specific exceptions, this can be done in a separate issue after a careful review of other uses of RuntimeError. On the other hand, if you and @methane will come to a consensus on this – I'll follow that. |
I'm neutral, because there are many RuntimeError in this script. |
I don't really care of a single except. |
This change is required to make python-dbg.py compatible with GDB versions before 7.3. (cherry picked from commit 661ca88)
No description provided.