-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
gh-112066: Use PyDict_SetDefaultRef in place of PyDict_SetDefault.
#112211
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
Conversation
encukou
left a comment
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.
+1 from me; IMO the chance of C-API WG having objections is low enough, let's be optimistic and merge this.
Python/compile.c
Outdated
| if (res < 0) { | ||
| Py_DECREF(key); | ||
| return NULL; | ||
| } | ||
| if (res == 1) { |
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.
Maybe merge them in single test != 0?
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 - I combined the cases.
…fault`. This changes a number of internal usages of `PyDict_SetDefault` to use `PyDict_SetDefaultRef`.
3899746 to
14a00f4
Compare
|
I've rebased this PR now that #112123 is merged. @serhiy-storchaka, would you please look over this? |
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
|
Nice change, it makes the code more readable. |
…fault`. (python#112211) This changes a number of internal usages of `PyDict_SetDefault` to use `PyDict_SetDefaultRef`. Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
This changes a number of internal usages of
PyDict_SetDefaultto usePyDict_SetDefaultRef.PyDict_SetDefaultthat returns a new reference (instead of a borrowed reference) #112066