From affee2a6b412c35351cbe671bb24141af9d955a2 Mon Sep 17 00:00:00 2001 From: Hai Shi Date: Thu, 6 Feb 2020 14:50:12 +0800 Subject: [PATCH 1/2] Port _contextvars extension module to multiphase initialization (PEP 489) --- Modules/_contextvarsmodule.c | 55 +++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/Modules/_contextvarsmodule.c b/Modules/_contextvarsmodule.c index 1abcdbfa921c27..d6d7f375d12307 100644 --- a/Modules/_contextvarsmodule.c +++ b/Modules/_contextvarsmodule.c @@ -27,33 +27,15 @@ static PyMethodDef _contextvars_methods[] = { {NULL, NULL} }; -static struct PyModuleDef _contextvarsmodule = { - PyModuleDef_HEAD_INIT, /* m_base */ - "_contextvars", /* m_name */ - module_doc, /* m_doc */ - -1, /* m_size */ - _contextvars_methods, /* m_methods */ - NULL, /* m_slots */ - NULL, /* m_traverse */ - NULL, /* m_clear */ - NULL, /* m_free */ -}; - -PyMODINIT_FUNC -PyInit__contextvars(void) +static int +_contextvars_exec(PyObject *m) { - PyObject *m = PyModule_Create(&_contextvarsmodule); - if (m == NULL) { - return NULL; - } - Py_INCREF(&PyContext_Type); if (PyModule_AddObject(m, "Context", (PyObject *)&PyContext_Type) < 0) { Py_DECREF(&PyContext_Type); - Py_DECREF(m); - return NULL; + return -1; } Py_INCREF(&PyContextVar_Type); @@ -61,8 +43,7 @@ PyInit__contextvars(void) (PyObject *)&PyContextVar_Type) < 0) { Py_DECREF(&PyContextVar_Type); - Py_DECREF(m); - return NULL; + return -1; } Py_INCREF(&PyContextToken_Type); @@ -70,9 +51,31 @@ PyInit__contextvars(void) (PyObject *)&PyContextToken_Type) < 0) { Py_DECREF(&PyContextToken_Type); - Py_DECREF(m); - return NULL; + return -1; } - return m; + return 0; +} + +static struct PyModuleDef_Slot _contextvars_slots[] = { + {Py_mod_exec, _contextvars_exec}, + {0, NULL} +}; + +static struct PyModuleDef _contextvarsmodule = { + PyModuleDef_HEAD_INIT, /* m_base */ + "_contextvars", /* m_name */ + module_doc, /* m_doc */ + 0, /* m_size */ + _contextvars_methods, /* m_methods */ + _contextvars_slots, /* m_slots */ + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL, /* m_free */ +}; + +PyMODINIT_FUNC +PyInit__contextvars(void) +{ + return PyModuleDef_Init(&_contextvarsmodule); } From 01c78d84a61d2972ab1bd282fa8e01039cbe00a1 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Thu, 6 Feb 2020 09:00:38 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core and Builtins/2020-02-06-09-00-35.bpo-1635741.oaxe1j.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2020-02-06-09-00-35.bpo-1635741.oaxe1j.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-02-06-09-00-35.bpo-1635741.oaxe1j.rst b/Misc/NEWS.d/next/Core and Builtins/2020-02-06-09-00-35.bpo-1635741.oaxe1j.rst new file mode 100644 index 00000000000000..49336f02a3e408 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2020-02-06-09-00-35.bpo-1635741.oaxe1j.rst @@ -0,0 +1 @@ +Port _contextvars extension module to multiphase initialization (:pep:`489`). \ No newline at end of file pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy