| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Sorry, something went wrong.
|
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 skip news label instead. |
Sorry, something went wrong.
There was a problem hiding this comment.
This PR adjusts dict-unpacking ({**obj} / DICT_UPDATE) error handling so that AttributeError raised from within a mapping’s keys() / __getitem__ is propagated, instead of being incorrectly rewritten as TypeError: '... object is not a mapping'.
Changes:
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Python/generated_cases.c.h | Regenerated tier-1 interpreter DICT_UPDATE case to preserve AttributeError from mapping internals. |
| Python/bytecodes.c | Updates the DICT_UPDATE bytecode definition’s error translation logic. |
| Lib/test/test_unpack_ex.py | Adds doctests to ensure {**obj} propagates AttributeError raised by keys() / __getitem__. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Sorry, something went wrong.
| PyObject *exc = PyErr_GetRaisedException(); | ||
| PyObject *keys = NULL; | ||
| int has_keys = PyObject_GetOptionalAttr(update_o, &_Py_ID(keys), &keys); | ||
|
|
||
| if (has_keys < 0) { |
There was a problem hiding this comment.
DICT_UPDATE now preserves the original AttributeError only when update_o has a keys attribute, but the tier-2 interpreter (Python/executor_cases.c.h) is generated from bytecodes.c and currently still contains the old unconditional conversion of AttributeError into TypeError. This will make behavior differ between tier-1 and tier-2 execution (and can break the new tests when tier-2 is enabled). Please regenerate/update the tier-2 cases so DICT_UPDATE matches this new logic everywhere.
Sorry, something went wrong.
|
Note that LLM-generated PRs are not accepted unless acknlowedge and properly reviewed. Read https://devguide.python.org/getting-started/generative-ai/ before opening other PRs please. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary\n- preserve AttributeError raised from mapping methods during dict unpacking\n- keep TypeError for objects that are not mappings\n- add a regression test in test_unpack_ex\n\n## Testing\n- PCbuild\build.bat -p x64 -c Release\n- PCbuild\amd64\python.exe -m test -v test_unpack_ex\n\nCloses #145876