gh-94808: Cover `LOAD_GLOBAL` for custom dict subtypes by sobolevn · Pull Request #96767 · python/cpython
I've covered several missing conditions in TARGET(LOAD_GLOBAL):
- The one where custom
globals()dict subtype raises nonKeyError:if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { goto error; } - Similar case where
__builtins__dict subtype raises nonKeyError: - Regular
NameErrorin a custom__builtins__dict subtype:if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { format_exc_check_arg( tstate, PyExc_NameError, NAME_ERROR_MSG, name); }
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the contribution.
| def __getitem__(self, key): | ||
| raise setonlyerror | ||
|
|
||
| class customdict(dict): # this one should not do anything fancy |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be defined just before the test that uses it (below). Ideally this function would be broken up - it's testing a lot of things.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Thanks!
Thanks @sobolevn for the PR, and @iritkatriel for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11.
🐍🍒⛏🤖
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request
Sorry, @sobolevn and @iritkatriel, I could not cleanly backport this to 3.10 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 044bcc1771fe7e2f8eba21793a72ba15e75e6715 3.10