Skip to content
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

Add explicit import to urllib.error in urllib.robotparser #128737

Merged
merged 2 commits into from
Jan 13, 2025

Conversation

picnixz
Copy link
Member

@picnixz picnixz commented Jan 11, 2025

It's not strictly needed, but I think it's better to have an explicit import (my IDE would complain) for:

try:
	f = urllib.request.urlopen(self.url)
except urllib.error.HTTPError as err:
    ...

@picnixz picnixz requested a review from berkerpeksag as a code owner January 11, 2025 12:09
@picnixz picnixz changed the title Add missing import in :mod:urllib.robotparser Add explicit import to urllib.error in urllib.robotparser Jan 11, 2025
@picnixz picnixz force-pushed the fix/urllib/explicit-import branch from fbc5849 to d238915 Compare January 11, 2025 12:11
@picnixz
Copy link
Member Author

picnixz commented Jan 13, 2025

@vstinner: I plan to merge this one. It's borderline a cosmetic change but I don't think we're doing this kind of trick elsewhere (urllib.error is implicitly accessible from urllib.robotparser because it's imported by urllib.request which is explicitly imported).

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.

LGTM

@picnixz picnixz merged commit 53e8942 into python:main Jan 13, 2025
40 checks passed
@picnixz picnixz deleted the fix/urllib/explicit-import branch January 13, 2025 16:15
@picnixz picnixz added needs backport to 3.12 bug and security fixes needs backport to 3.13 bugs and security fixes labels Jan 13, 2025
@miss-islington-app
Copy link

Thanks @picnixz for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Thanks @picnixz for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 13, 2025
…8737)

(cherry picked from commit 53e8942)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@bedevere-app
Copy link

bedevere-app bot commented Jan 13, 2025

GH-128793 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Jan 13, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 13, 2025
…8737)

(cherry picked from commit 53e8942)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@bedevere-app
Copy link

bedevere-app bot commented Jan 13, 2025

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

@bedevere-app bedevere-app bot removed the needs backport to 3.12 bug and security fixes label Jan 13, 2025
picnixz added a commit that referenced this pull request Jan 13, 2025
…28737) (#128794)

Explicitly import `urllib.error` in `urllib.robotparser` (GH-128737)
(cherry picked from commit 53e8942)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
picnixz added a commit that referenced this pull request Jan 13, 2025
…28737) (#128793)

Explicitly import `urllib.error` in `urllib.robotparser` (GH-128737)
(cherry picked from commit 53e8942)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants