This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Port the standard library to PEP 489 multiphase initialization
Type: enhancement Stage: resolved
Components: Extension Modules Versions: Python 3.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Py_Finalize() doesn't clear all Python objects at exit
View: 1635741
Assigned To: Nosy List: Dormouse759, ncoghlan, petr.viktorin, vstinner
Priority: normal Keywords: patch

Created on 2017-10-24 15:08 by Dormouse759, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4108 merged Dormouse759, 2017-10-24 15:18
Messages (6)
msg304914 - (view) Author: Marcel Plch (Dormouse759) * Date: 2017-10-24 15:08
PEP 489 introduced multiphase initialization of extension and built-in modules.
Now, almost no module in the standard library supports this feature. This should be improved to prepare Python for better testing of subinterpreters.

Many benefits of PEP 489 don't apply to stdlib modules. However, the PEP effectively says that by using multi-phase init, the module author "promises" that the module is "subinterpreter-friendly" [0]. So, when porting, each module should be checked that it e.g. doesn't use mutable process-global state.

I'd like to port stdlib to multi-phase init, starting with the easier modules, to:
    - get familiar with contributing to CPython,
    - check and track which modules are already "subinterpreter-friendly", and
    - figure out how and where PEP 489 is lacking (beyond what is discussed in the PEP itself).


[0]: https://www.python.org/dev/peps/pep-0489/#subinterpreters-and-interpreter-reloading
msg304916 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) Date: 2017-10-24 15:15
FWIW, Marcel is an intern in my team, tasked to learn CPython internals by trying to improve subinterpreter support. If I don't comment on his issues it's because we discussed privately beforehand.
msg343182 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) Date: 2019-05-22 11:51
New changeset 33e71e01e95506cf8d93fd68251fc56352bc7b39 by Petr Viktorin (Marcel Plch) in branch 'master':
bpo-31862: Port binascii to PEP 489 multiphase initialization (GH-4108)
https://github.com/python/cpython/commit/33e71e01e95506cf8d93fd68251fc56352bc7b39
msg376487 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-09-07 13:53
I marked bpo-15681 "PEP 3121 refactoring applied to binascii module" as a duplicate of this issue.
msg376488 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-09-07 13:53
See also bpo-1635741 "Py_Finalize() doesn't clear all Python objects at exit": many extension modules have been ported to multi-phase initialization API (PEP 489) there.
msg376489 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-09-07 13:55
I prefer to track the work in a single issue. Even if bpo-1635741 contains many unrelated changes, I prefer to continue to use bpo-1635741 to track the work on "porting the standard library to PEP 489 multiphase initialization".
History
Date User Action Args
2022-04-11 14:58:53adminsetgithub: 76043
2020-09-07 13:55:42vstinnerunlinkissue15681 superseder
2020-09-07 13:55:38vstinnersetstatus: open -> closed
superseder: Py_Finalize() doesn't clear all Python objects at exit
messages: + msg376489

resolution: duplicate
stage: patch review -> resolved
2020-09-07 13:53:52vstinnersetmessages: + msg376488
2020-09-07 13:53:05vstinnersetnosy: + vstinner
messages: + msg376487
2020-09-07 13:52:38vstinnerlinkissue15681 superseder
2020-01-16 16:39:59Mariattasetpull_requests: - pull_request13420
2019-05-22 19:47:12sir-sigurdsetpull_requests: + pull_request13420
2019-05-22 11:51:36petr.viktorinsetmessages: + msg343182
2017-10-24 15:18:34Dormouse759setkeywords: + patch
stage: patch review
pull_requests: + pull_request4078
2017-10-24 15:15:52petr.viktorinsetmessages: + msg304916
2017-10-24 15:08:56Dormouse759create