-
-
Notifications
You must be signed in to change notification settings - Fork 29.2k
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
gh-118598: Improve suggestion of TypeError when attempting to iterate over an integer #118602
base: main
Are you sure you want to change the base?
Conversation
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
@@ -130,7 +130,7 @@ | |||
Traceback (most recent call last): | |||
File "<pyshell#4>", line 1, in -toplevel- | |||
(i for i in 6) | |||
TypeError: 'int' object is not iterable | |||
TypeError: 'int' object is not iterable. Did you mean: 'range('int')'? |
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.
Single quotes within single quotes does not work. Just range(...)
or range(<int>)
would be better. Change would apply to other patches below.
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.
Note it looks like there isn't consensus on the issue about the best scope for this message.
Adding this to traceback.py based on substring checks also feels a little broad in my opinion, I'd prefer if error message was changed where it is raised.
Corresponding issue: #118598