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-102541: Fix Helper.help("mod") for non-existent mod by Eclips4 · Pull Request #105934 · python/cpython

Conversation

@Eclips4

@Eclips4 Eclips4 commented Jun 20, 2023 •
edited by terryjreedy
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

If the output arg to Helper() is a stream rather than the default None, which means 'page to stdout', the ImportError from pydoc.resolve is currently not caught in `pydoc.doc. The same error is caught when output is None.

import pydoc
from io import StringIO

input = StringIO()
output = StringIO()
help = pydoc.Helper(input, output)
help.help("abd")
input.close()
output.close()

Traceback:

./python example.py
Running debug|x64 interpreter...
Traceback (most recent call last):
  File "C:\Users\KIRILL-1\CLionProjects\cpython\example.py", line 7, in <module>
    help.help("abd", is_cli=True)
  File "C:\Users\KIRILL-1\CLionProjects\cpython\Lib\pydoc.py", line 2067, in help
    elif request: doc(request, 'Help on %s:', output=self._output, is_cli=is_cli)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\KIRILL-1\CLionProjects\cpython\Lib\pydoc.py", line 1793, in doc
    output.write(render_doc(thing, title, forceload, plaintext))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\KIRILL-1\CLionProjects\cpython\Lib\pydoc.py", line 1760, in render_doc
    object, name = resolve(thing, forceload)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\KIRILL-1\CLionProjects\cpython\Lib\pydoc.py", line 1746, in resolve
    raise ImportError('''\
ImportError: No Python documentation found for 'abd'.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.

EDITED by terryjreedy July 1, 2023 to better describe the issue, so I could review the patch,
and show the current result after the merge of the first PR for the issue. Instead of the last line
there were about 15 lines that repeated the Traceback.

  • Issue: help CLI shows a traceback when import failed #102541

Sorry, something went wrong.

Uh oh!

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

All reactions
@Eclips4
pythongh-102541: Fix Helper.help when output is non default
e6fb90b
@bedevere-bot bedevere-bot added the awaiting review label Jun 20, 2023
@bedevere-bot bedevere-bot mentioned this pull request Jun 20, 2023
help CLI shows a traceback when import failed #102541
Closed
@Eclips4

Eclips4 commented Jun 20, 2023

Copy link
Copy Markdown
Member Author

cc @corona10

All reactions

Sorry, something went wrong.

Uh oh!

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

@corona10

corona10 commented Jun 20, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

@terryjreedy @Yhg1s @ambv

I am out of OSS for this month. If this PR is urgent, I would like to request reviewing of this PR to other reviewers.

All reactions

Sorry, something went wrong.

Uh oh!

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

@Eclips4
Add test
c25776c
sobolevn
sobolevn reviewed Jun 20, 2023
View reviewed changes
Comment thread Lib/test/test_pydoc.py Resolved

Uh oh!

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

@Eclips4
Rewrite test using the with keyword
296c0ba
@corona10
corona10 requested review from Yhg1s, ambv and terryjreedy June 20, 2023 13:04
@terryjreedy terryjreedy changed the title gh-102541: Fix Helper.help when output is non default gh-102541: Fix Helper.help("mod") for non-existent mod Jul 1, 2023
terryjreedy
terryjreedy reviewed Jul 1, 2023
View reviewed changes
Comment thread Lib/pydoc.py Resolved

Uh oh!

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

terryjreedy added 2 commits July 1, 2023 16:34
@terryjreedy
Update Lib/pydoc.py
c597019
@terryjreedy
Merge branch 'main' into issue-102541
834ea6d
@terryjreedy terryjreedy added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Jul 1, 2023
terryjreedy added 3 commits July 1, 2023 16:41
@terryjreedy
blurb
7b117ac
@terryjreedy
Update pydoc.py
f4eb39d
@terryjreedy
Update pydoc.py
8868e95
@terryjreedy
terryjreedy merged commit 0530f4f into python:main Jul 1, 2023
@miss-islington

miss-islington commented Jul 1, 2023

Copy link
Copy Markdown
Contributor

Thanks @Eclips4 for the PR, and @terryjreedy for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot bedevere-bot removed the awaiting review label Jul 1, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 1, 2023
@Eclips4 @terryjreedy @miss-islington
pythongh-102541: Fix Helper.help("mod") for non-existent mod (pythonG…
f669aaa
…H-105934)

If the output arg to Helper() is a stream rather than the default None, which means 'page to stdout', the ImportError from pydoc.resolve is currently not caught in pydoc.doc. The same error is caught when output is None.
---------

(cherry picked from commit 0530f4f)

Co-authored-by: Kirill Podoprigora <[email protected]>
Co-authored-by: Terry Jan Reedy <[email protected]>
@bedevere-bot

bedevere-bot commented Jul 1, 2023

Copy link
Copy Markdown

GH-106322 is a backport of this pull request to the 3.12 branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot bedevere-bot removed the needs backport to 3.12 only security fixes label Jul 1, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 1, 2023
@Eclips4 @terryjreedy @miss-islington
pythongh-102541: Fix Helper.help("mod") for non-existent mod (pythonG…
6b55c26
…H-105934)

If the output arg to Helper() is a stream rather than the default None, which means 'page to stdout', the ImportError from pydoc.resolve is currently not caught in pydoc.doc. The same error is caught when output is None.
---------

(cherry picked from commit 0530f4f)

Co-authored-by: Kirill Podoprigora <[email protected]>
Co-authored-by: Terry Jan Reedy <[email protected]>
@bedevere-bot

bedevere-bot commented Jul 1, 2023

Copy link
Copy Markdown

GH-106323 is a backport of this pull request to the 3.11 branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Jul 1, 2023
terryjreedy added a commit that referenced this pull request Jul 1, 2023
@miss-islington @Eclips4 @terryjreedy
[3.11] gh-102541: Fix Helper.help("mod") for non-existent mod (GH-105934
9e33586
) (#106323)

gh-102541: Fix Helper.help("mod") for non-existent mod (GH-105934)

If the output arg to Helper() is a stream rather than the default None, which means 'page to stdout', the ImportError from pydoc.resolve is currently not caught in pydoc.doc. The same error is caught when output is None.
---------

(cherry picked from commit 0530f4f)

Co-authored-by: Kirill Podoprigora <[email protected]>
Co-authored-by: Terry Jan Reedy <[email protected]>
terryjreedy added a commit that referenced this pull request Jul 1, 2023
@miss-islington @Eclips4 @terryjreedy
[3.12] gh-102541: Fix Helper.help("mod") for non-existent mod (GH-105934
730c873
) (#106322)

gh-102541: Fix Helper.help("mod") for non-existent mod (GH-105934)

If the output arg to Helper() is a stream rather than the default None, which means 'page to stdout', the ImportError from pydoc.resolve is currently not caught in pydoc.doc. The same error is caught when output is None.
---------

(cherry picked from commit 0530f4f)

Co-authored-by: Kirill Podoprigora <[email protected]>
Co-authored-by: Terry Jan Reedy <[email protected]>
@Eclips4
Eclips4 deleted the issue-102541 branch July 2, 2023 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sobolevn sobolevn sobolevn left review comments
@terryjreedy terryjreedy terryjreedy left review comments
@ambv ambv Awaiting requested review from ambv
@Yhg1s Yhg1s Awaiting requested review from Yhg1s

Uh oh!

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

Assignees

No one assigned

Labels

None yet

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.

6 participants

@Eclips4 @corona10 @miss-islington @bedevere-bot @sobolevn @terryjreedy
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.