Repository navigation
bpo-40671: Prepare _hashlib for PEP 489 (GH-20180) - #20180
Conversation
vstinner
left a comment
There was a problem hiding this comment.
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).
|
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 <christian@python.org>
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. |
| PyMODINIT_FUNC | ||
| PyInit__hashlib(void) | ||
| { | ||
| PyObject *m = PyState_FindModule(&_hashlibmodule); |
There was a problem hiding this comment.
nitpick from victor: using mod or module would be more exact ;)
There was a problem hiding this comment.
$ 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.
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 <christian@python.org>
|
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 <christian@python.org>
|
GH-20381 is a backport of this pull request to the 3.9 branch. |
Prepare
_hashlibmodule for PEP 489 module initialization and usePyModule_AddType.Signed-off-by: Christian Heimes christian@python.org
https://bugs.python.org/issue40671
Automerge-Triggered-By: @tiran