GeezerVison is showing github.com — gh-102799: Let pydoc use the exception instead of sys.exc_info by iritkatriel · Pull Request #102830 · python/cpython
Conversation
iritkatriel
commented
Mar 19, 2023
•
edited by bedevere-bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
terryjreedy
left a comment
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
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.
Except for suggestions, looks good. I satisfied my question.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
392
to
396
|
|
if not isinstance(exc_info, tuple):
|
|
|
assert isinstance(exc_info, BaseException)
|
|
|
exc_info = type(exc_info), exc_info, exc_info.__traceback__
|
|
|
self.filename = filename
|
|
|
self.exc, self.value, self.tb = exc_info
|
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.
Separate suggestions:
- Keep handling of two args in order. First first and second second. Handling first in middle of second is unnecessary confusion.
- Handle two cases of second separately. Don't create tuple just to unpack. Unpacking makes it slightly more obvious that same attributes are defined, but pack/unpack makes it harder to see what object is assigned to each attribute.
|
if not isinstance(exc_info, tuple): |
|
assert isinstance(exc_info, BaseException) |
|
exc_info = type(exc_info), exc_info, exc_info.__traceback__ |
|
self.filename = filename |
|
self.exc, self.value, self.tb = exc_info |
|
self.filename = filename |
|
if isinstance(exc_info, tuple): |
|
self.exc, self.value, self.tb = exc_info |
|
else: |
|
assert isinstance(exc_info, BaseException) |
|
self.exc = type(exc_info) |
|
self.value = exc_info |
|
self.tb = exc_info.__traceback__ |
I am tempted to think that no user will ever raise this exception. pydoc is only documented as a command-line app, not as importable library. But this is not idlelib. Can/should we emit a DeprecationWarning in the isinstance clause? It could then be removed someday. Since there is no doc of the module content, no changed notice is needed.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
iritkatriel reacted with thumbs up emoji
|
|
del sys.modules[key]
|
|
|
module = __import__(path)
|
|
|
except:
|
|
|
except BaseException as e:
|
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 personally prefer 'err' to 'e'. I have no idea of any general consensus.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
iritkatriel reacted with thumbs up emoji
Uh oh!
There was an error while loading. Please reload this page.
iritkatriel
changed the title
gh-102799: pydoc doesn't need to use sys.exc_info
gh-102799: Let pydoc use the exception instead of sys.exc_info
Mar 21, 2023
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|