Skip to content

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

Merged
merged 1 commit into from
Mar 1, 2017

Conversation

abalkin
Copy link
Member

@abalkin abalkin commented Mar 1, 2017

No description provided.

@mention-bot
Copy link

@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.

@abalkin
Copy link
Member Author

abalkin commented Mar 1, 2017

@the-knights-who-say-ni - I don't see anythyng wrong with my b.p.o details:

screen shot 2017-02-28 at 9 52 42 pm

@abalkin
Copy link
Member Author

abalkin commented Mar 1, 2017

@methane - it looks like you introduced this issue in d7d2bc8. Could you, please review my fix?

@abalkin abalkin self-assigned this Mar 1, 2017
@abalkin abalkin requested a review from methane March 1, 2017 03:06
@methane methane changed the title Fixes bpo-29680: Older gdb does not have gdb.error. bpo-29680: Older gdb does not have gdb.error. Mar 1, 2017
try:
_gdb_error = gdb.error
except AttributeError:
_gdb_error = RuntimeError
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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'>]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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.

@Mariatta
Copy link
Member

Mariatta commented Mar 1, 2017

@abalkin, somehow your change was committed under GitHub username abelopolsky instead of abalkin 🤔

@abalkin
Copy link
Member Author

abalkin commented Mar 1, 2017

@Mariatta - I can probably fix that.

Copy link
Member

@vstinner vstinner left a 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:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;f=gdb/python/python.c;h=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.

@vstinner
Copy link
Member

vstinner commented Mar 1, 2017

@abalkin abalkin added the cherry-pick for 3.6 label 5 hours ago

No, you should use "needs backport to 3.6" label. The other label is for the cherry-pick PR ;-)

@vstinner
Copy link
Member

vstinner commented Mar 1, 2017

@abalkin, somehow your change was committed under GitHub username abelopolsky instead of abalkin 🤔

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.

@vstinner
Copy link
Member

vstinner commented Mar 1, 2017

There are many except RuntimeError in this file and most of them may be gdb.error.

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!

@abalkin
Copy link
Member Author

abalkin commented Mar 1, 2017

@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.

@methane
Copy link
Member

methane commented Mar 1, 2017

I'm neutral, because there are many RuntimeError in this script.

@vstinner vstinner dismissed their stale review March 1, 2017 17:36

I don't really care of a single except

@vstinner
Copy link
Member

vstinner commented Mar 1, 2017

I don't really care of a single except.

@abalkin abalkin merged commit 661ca88 into python:master Mar 1, 2017
@abalkin abalkin deleted the bpo-29680 branch March 1, 2017 18:16
Mariatta pushed a commit to Mariatta/cpython that referenced this pull request Mar 7, 2017
This change is required to make python-dbg.py compatible with GDB versions before 7.3.
(cherry picked from commit 661ca88)
Mariatta added a commit that referenced this pull request Mar 7, 2017
This change is required to make python-dbg.py compatible with GDB versions before 7.3.
(cherry picked from commit 661ca88)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants