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-114091: Reword error message for unawaitable types#114090

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

Conversation

@swfarnsworth
Copy link
Contributor

@swfarnsworthswfarnsworth commentedJan 15, 2024
edited by bedevere-appbot
Loading

Currently, attempting to await something that cannot be awaited results in this error message:

importasyncioasyncdefmain():await1asyncio.run(main())# TypeError: object int can't be used in 'await' expression

I recently encountered this for the first time when the unawaitable object was a method (which was not being called), and found the phrase "object method" unclear. This PR changes the error message so that the name of the class precedes the word "object" and appears in single quotes. A similar construction appears elsewhere in the code base.

>>>1[2]TypeError:'int'objectisnotsubscriptable

 
Thank you to@JelleZijlstra and@godlygeek for their input to this PR (though they do not necessarily endorse it).

"object $type can't be ..." -> "'$type' object can't be ..."
@ghost
Copy link

ghost commentedJan 15, 2024
edited by ghost
Loading

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app
Copy link

Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply theskip news label instead.

@JelleZijlstra
Copy link
Member

This will need a NEWS entry since it's a user-visible change. That means you'll also need to create an issue, then rename this PR with the issue number (e.g.,"gh-110491: Reword error message...) and use that issue number in the NEWS entry (step 8 inhttps://devguide.python.org/#quick-reference).

As for the contents, I like the change. What do you think though of instead changing the text of "'int' object is not awaitable'? That is even shorter, seems just as clear, and matches other errors like the subscript one.

@swfarnsworth
Copy link
ContributorAuthor

swfarnsworth commentedJan 15, 2024
edited
Loading

What do you think though of instead changing the text of "'int' object is not awaitable"?

I agree and will implement this change.

@swfarnsworthswfarnsworth changed the titleReword error message for unawaitable typesgh-114091: Reword error message for unawaitable typesJan 15, 2024
@gvanrossum
Copy link
Member

This doesn't look like something that would require an issue (though it does need a news blurb). IIRC it's possible to have a news entry without an issue? (You can try using the PR number as issue number in the blurb form.)

@JelleZijlstra
Copy link
Member

IIRC it's possible to have a news entry without an issue?

I don't think so.

"can't be used in 'await' expression" -> "can't be awaited"
@bedevere-app
Copy link

Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply theskip news label instead.

@kumaraditya303kumaraditya303 merged commit2c7209a intopython:mainJun 17, 2024
mrahtz pushed a commit to mrahtz/cpython that referenced this pull requestJun 30, 2024
noahbkim pushed a commit to hudson-trading/cpython that referenced this pull requestJul 11, 2024
estyxx pushed a commit to estyxx/cpython that referenced this pull requestJul 17, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@kumaraditya303kumaraditya303kumaraditya303 approved these changes

@markshannonmarkshannonAwaiting requested review from markshannonmarkshannon is a code owner

@1st11st1Awaiting requested review from 1st11st1 is a code owner

@asvetlovasvetlovAwaiting requested review from asvetlovasvetlov is a code owner

@gvanrossumgvanrossumAwaiting requested review from gvanrossum

@willingcwillingcAwaiting requested review from willingcwillingc is a code owner

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@swfarnsworth@JelleZijlstra@gvanrossum@kumaraditya303@Eclips4

[8]ページ先頭

©2009-2025 Movatter.jp