gh-105736: Sync pure python version of OrderedDict with the C version#108098
gh-105736: Sync pure python version of OrderedDict with the C version#108098ambv merged 8 commits intopython:mainfrom
Conversation
|
🤖 New build scheduled with the buildbot fleet by @rhettinger for commit 4f04b7e 🤖 If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again. |
This reverts commit 4758750.
|
🤖 New build scheduled with the buildbot fleet by @rhettinger for commit d3179bc 🤖 If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again. |
|
I can confirm the new tests fail without the fix 👍🏻 One thing I'm trying to find is why we needed the So I guess skipping the |
The In contrast, the |
|
By whom can it be called multiple times? I mean, yes, theoretically you can explicitly grab (yes, I agree that |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
LGTM. And the resulting code looks clearer.
Moving the code from __init__ to __new__ can break pickling, but OrderedDict uses full constructor instead of __new__ in pickling, so it is safe from this side.
|
Thanks @rhettinger for the PR, and @ambv for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12. |
|
GH-108200 is a backport of this pull request to the 3.12 branch. |
|
GH-108201 is a backport of this pull request to the 3.11 branch. |
…ersion (pythonGH-108098) (cherry picked from commit 20cc90c) Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
…ersion (pythonGH-108098) (cherry picked from commit 20cc90c) Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
|
Side note. "gh-" in the title should be in lower case, and the issue number should be separated by a colon from the rest of the text. I think this is the reason why other Raymond's PRs were not automatically linked from the corresponding issue. |
This solves a problem noticed in the referenced issue. When
__init__is overridden, the C version is still usable but the pure Python version fails. The solution is to have the internal invariants sets up in__new__rather than__init__.The original copy/pickle issue still remains.