-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-40671: Prepare _hashlib for PEP 489 (GH-20180) #20180
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
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 hold this PR until master becomes Python 3.10. It's too late for 3.9, and I don't think that it's worth it to modify 3.9. This PR is mostly useful for subinterpreters which remains an experimental feature (especially with per-interpreter GIL).
Misc/NEWS.d/next/Library/2020-05-18-15-26-31.bpo-40671.NeZ9Cy.rst
Outdated
Show resolved
Hide resolved
Note: I'm happy to see my gc module debug enhancements working as expected :-)
Sadly, _PyObject_Dump() fails to render a dictionary which contains a "freed" item. That's another possible enhancement ;-) |
I have rebased the PR on master and submitted a new build. The Ubuntu builder was acting up. |
This is a minor and internal change. Other modules are already using the new API. I prefer to backport the change to 3.9 to reduce maintenance my burden. |
It's a new feature: it becomes possible to have two separated instances of the module. There is a risk of regression. |
Prepare ``_hashlib`` module for PEP 489 module initialization and use ``PyModule_AddType``. Signed-off-by: Christian Heimes <[email protected]>
Sounds plausible. I have changed the PR so salvage as much of the changes without breaking behavior. |
@shihai1991 could you take another look, please? I modified the PR to prepare the hashlib module for PEP 489 but does not switch to the new API. I'd like to keep the code in 3.9 and master as close as possible to reduce my maintenance overhead. |
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.
LGTM.
PyMODINIT_FUNC | ||
PyInit__hashlib(void) | ||
{ | ||
PyObject *m = PyState_FindModule(&_hashlibmodule); |
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.
nitpick from victor: using mod
or module
would be more exact ;)
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.
$ grep -R "\sPyObject \*m[,;]" Modules/*.c | wc -l
40
$ grep -R "\sPyObject \*module[,;]" Modules/*.c | wc -l
8
m
is common.
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.
Hm, we will update all m
vars when we port extension module to pep489 ; )
Since master is now 3.10, is this just waiting for someone to hit the approve button? |
Yes, I'm waiting for approval. Please note that I modified the PR so that it does not change behavior at all so it can land in 3.9. I'll do another PR on top that will enable PR 489 behavior for 3.10 only. |
Thanks @tiran for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9. |
(cherry picked from commit 20c22db) Co-authored-by: Christian Heimes <[email protected]>
GH-20378 is a backport of this pull request to the 3.9 branch. |
Thanks @tiran for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9. |
(cherry picked from commit 20c22db) Co-authored-by: Christian Heimes <[email protected]>
GH-20381 is a backport of this pull request to the 3.9 branch. |
(cherry picked from commit 20c22db) Co-authored-by: Christian Heimes <[email protected]>
Prepare
_hashlib
module for PEP 489 module initialization and usePyModule_AddType
.Signed-off-by: Christian Heimes [email protected]
https://bugs.python.org/issue40671
Automerge-Triggered-By: @tiran