-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-122239: Add actual count in unbalanced unpacking error message when possible #122244
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
71d53eb
add actual iterable count in error message
tusharsadhwani e55ce9c
Merge remote-tracking branch 'upstream/main' into argcnt-errmsg
tusharsadhwani 04595e5
add test for non-sequence type
tusharsadhwani b8dc5eb
make test pass for non-sequences
tusharsadhwani e444582
Add news entry
tusharsadhwani 525447c
rephase news
tusharsadhwani 272cc6a
PEP7
tusharsadhwani 43beedf
Fallback to PyMapping_Size
tusharsadhwani f40e782
remove whitespace
tusharsadhwani 32dbf36
Merge branch 'main' into argcnt-errmsg
tusharsadhwani 0c741e2
Update Python/ceval.c
tusharsadhwani 0a2f9ba
remove stale comment
tusharsadhwani ea5a84a
Handle weird cases
tusharsadhwani 69a5f9f
lint
tusharsadhwani cd0d534
use ChainExceptions1 to simplify code
tusharsadhwani 088f90f
handle BaseException propagation
tusharsadhwani d8df9bc
remove whitespace
tusharsadhwani 95a41b5
Merge branch 'main' into argcnt-errmsg
tusharsadhwani 6e8c53f
flip the logic to simplify it
tusharsadhwani a5d926f
rollback to the simpler approach
tusharsadhwani fe9be07
line length
tusharsadhwani 4bcb19f
Use PyDict_Size for dicts
tusharsadhwani d68ba12
simplify code
tusharsadhwani f183de8
Apply suggestions from code review
tusharsadhwani 1b4c21b
indentation fix
tusharsadhwani bb1f132
Update Misc/NEWS.d/next/Core_and_Builtins/2024-07-25-01-45-21.gh-issu…
tusharsadhwani 9b94761
Merge branch 'main' into argcnt-errmsg
tusharsadhwani b05bd53
Add whatsnew entry
tusharsadhwani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update Python/ceval.c
Co-authored-by: blhsing <blhsing@gmail.com>
- Loading branch information
commit 0c741e27b1f0d5efda9690717cc5f6b1b94bead6
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
Please consider, and test, evil classes that lie about their size. For example:
At this level, I don't think we want to print
(expected 2, got 2), even if user is at fault here.In other evil classes,
__len__can fail with an exception. Please test this.IMO, if it's not a
TypeError/AttributeError, and especially if it's aBaseExceptionbut notException, it needs to be chained (e.g. usingPyException_SetContext).Other evil classes can have side effects, or take a long time. IMO, that's OK -- an extra
__len__call shouldn't hurt.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.
Thanks for catching this, I'll test and take care of these cases.
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.
I think I've handled the weird cases now, but I couldn't figure out what would raise an
AttributeErrorin the normal case, so I'm only ignoringTypeError's context right now.There's also a bunch of code duplication for
_PyErr_Format, should it be deduped in some way?