Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-125522: Fix bare except intest_uuid#129018

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
iritkatriel merged 2 commits intopython:mainfromtomasr8:test-uuid-bare-except
Jan 29, 2025

Conversation

@tomasr8
Copy link
Member

@tomasr8tomasr8 commentedJan 19, 2025
edited by bedevere-appbot
Loading

The intent of the helper function is only to check whether a module can be imported, so catching all exceptions could hide other issues.

(I'm adding the backport labels seeing as the other PRs were also backported)

@tomasr8tomasr8 added skip news needs backport to 3.12only security fixes needs backport to 3.13bugs and security fixes labelsJan 19, 2025
@bedevere-appbedevere-appbot added the testsTests in the Lib/test dir labelJan 19, 2025
@graingertgraingert self-requested a reviewJanuary 19, 2025 12:05
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
__import__(name)
returnTrue
except:
exceptModuleNotFoundError:
Copy link
Contributor

Choose a reason for hiding this comment

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

If you want to be maximally pedantic you can go even more specific:

Suggested change
exceptModuleNotFoundError:
exceptModuleNotFoundErrorase:
ife.name==name:
returnFalse
raise

Eg if a module is successfully found but then imports another module which isn't found, this will raise but the code in the PR will not

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

There's only one other place in the repo that looks ate.name so this seems to be a pretty uncommon pattern and maybe not worth for test code? Though I don't have a strong preference either way :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I'm cool with it either way

tomasr8 reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Alright, I'll keep it as is for now and let's see what other reviewers think :)

__import__(name)
returnTrue
except:
exceptModuleNotFoundError:
Copy link
Member

Choose a reason for hiding this comment

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

Are we sure this is the only exception type that can come from__import__(name)?

I guess since it's a test it's fine to assume (if the tests pass).

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Not 100% sure, but I think anything else would be unexpected here and would warrant looking into

@iritkatrieliritkatriel merged commita1a4e9f intopython:mainJan 29, 2025
41 checks passed
@miss-islington-app
Copy link

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestJan 29, 2025
(cherry picked from commita1a4e9f)Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
@bedevere-app
Copy link

GH-129455 is a backport of this pull request to the3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13bugs and security fixes labelJan 29, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestJan 29, 2025
(cherry picked from commita1a4e9f)Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
@bedevere-app
Copy link

GH-129456 is a backport of this pull request to the3.12 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.12only security fixes labelJan 29, 2025
@tomasr8tomasr8 deleted the test-uuid-bare-except branchJanuary 29, 2025 21:05
iritkatriel pushed a commit that referenced this pull requestJan 29, 2025
gh-125522: Fix bare except in `test_uuid` (GH-129018)(cherry picked from commita1a4e9f)Co-authored-by: Tomas R <tomas.roun8@gmail.com>
iritkatriel pushed a commit that referenced this pull requestJan 29, 2025
gh-125522: Fix bare except in `test_uuid` (GH-129018)(cherry picked from commita1a4e9f)Co-authored-by: Tomas R <tomas.roun8@gmail.com>
srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this pull requestFeb 7, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@graingertgraingertgraingert approved these changes

@iritkatrieliritkatrieliritkatriel approved these changes

Assignees

No one assigned

Labels

skip newstestsTests in the Lib/test dir

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@tomasr8@graingert@iritkatriel

[8]ページ先頭

©2009-2025 Movatter.jp