GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@iritkatriel iritkatriel commented Mar 19, 2023 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: some usages of sys.exc_info can be replaced by more modern code #102799

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@iritkatriel
pythongh-102799: pydoc doesn't need to use sys.exc_info
db6a8a9
@bedevere-bot bedevere-bot mentioned this pull request Mar 19, 2023
some usages of sys.exc_info can be replaced by more modern code #102799
Closed
@bedevere-bot bedevere-bot added the awaiting core review label Mar 19, 2023
@iritkatriel iritkatriel added the skip news label Mar 19, 2023
terryjreedy
terryjreedy reviewed Mar 20, 2023
View reviewed changes

@terryjreedy terryjreedy left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

All reactions
Comment thread Lib/pydoc.py Outdated
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

@terryjreedy terryjreedy Mar 20, 2023

Copy link
Copy Markdown
Member

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:

  1. Keep handling of two args in order. First first and second second. Handling first in middle of second is unnecessary confusion.
  2. 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.
Suggested change
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
All reactions
  • 👍 1 reaction
Comment thread Lib/pydoc.py Outdated
del sys.modules[key]
module = __import__(path)
except:
except BaseException as e:

@terryjreedy terryjreedy Mar 20, 2023

Copy link
Copy Markdown
Member

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
All reactions
  • 👍 1 reaction
@iritkatriel
implement code review suggestions
84fd615
iritkatriel
iritkatriel commented Mar 20, 2023
View reviewed changes
Comment thread Lib/pydoc.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@iritkatriel 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
@iritkatriel
iritkatriel merged commit 868490e into python:main Mar 21, 2023
@bedevere-bot bedevere-bot removed the awaiting core review label Mar 21, 2023
Fidget-Spinner pushed a commit to Fidget-Spinner/cpython that referenced this pull request Mar 27, 2023
@iritkatriel @Fidget-Spinner
pythongh-102799: Let pydoc use the exception instead of sys.exc_info (p…
52172d3
…ython#102830)
@iritkatriel
iritkatriel deleted the pydoc branch April 3, 2023 17:42
warsaw pushed a commit to warsaw/cpython that referenced this pull request Apr 11, 2023
@iritkatriel @warsaw
pythongh-102799: Let pydoc use the exception instead of sys.exc_info (p…
9a62a94
…ython#102830)
donbarbos added a commit to donbarbos/typeshed that referenced this pull request Jan 10, 2026
@donbarbos
[pydoc] Update ErrorDuringImport
9b162ad
Source: python/cpython#102830
@donbarbos donbarbos mentioned this pull request Jan 10, 2026
[pydoc] Update ErrorDuringImport python/typeshed#15251
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@terryjreedy terryjreedy terryjreedy left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

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.

3 participants

@iritkatriel @terryjreedy @bedevere-bot
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.