diff options
author | Victor Stinner <vstinner@python.org> | 2020-11-04 16:33:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-04 16:33:55 +0100 |
commit | 988f1ec8d2643a0d00851903abcdae90d57ac0e6 (patch) | |
tree | a1cd6775adef2af21bcdfd29d140af1c80ff38fc /Modules/_contextvarsmodule.c | |
parent | cfb41e80c1ac5940ec6f2246c9ab4a3d16ef757e (diff) | |
download | cpython-git-988f1ec8d2643a0d00851903abcdae90d57ac0e6.tar.gz |
bpo-1635741: _contextvars uses PyModule_AddType() (GH-23147)
Replace PyModule_AddObject() with PyModule_AddType() in the
_contextvars module (Python-ast.c).
Add also the module name to _contextvars types name.
Diffstat (limited to 'Modules/_contextvarsmodule.c')
-rw-r--r-- | Modules/_contextvarsmodule.c | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/Modules/_contextvarsmodule.c b/Modules/_contextvarsmodule.c index d6d7f375d1..d13b5962c1 100644 --- a/Modules/_contextvarsmodule.c +++ b/Modules/_contextvarsmodule.c @@ -30,30 +30,15 @@ static PyMethodDef _contextvars_methods[] = { static int _contextvars_exec(PyObject *m) { - Py_INCREF(&PyContext_Type); - if (PyModule_AddObject(m, "Context", - (PyObject *)&PyContext_Type) < 0) - { - Py_DECREF(&PyContext_Type); + if (PyModule_AddType(m, &PyContext_Type) < 0) { return -1; } - - Py_INCREF(&PyContextVar_Type); - if (PyModule_AddObject(m, "ContextVar", - (PyObject *)&PyContextVar_Type) < 0) - { - Py_DECREF(&PyContextVar_Type); + if (PyModule_AddType(m, &PyContextVar_Type) < 0) { return -1; } - - Py_INCREF(&PyContextToken_Type); - if (PyModule_AddObject(m, "Token", - (PyObject *)&PyContextToken_Type) < 0) - { - Py_DECREF(&PyContextToken_Type); + if (PyModule_AddType(m, &PyContextToken_Type) < 0) { return -1; } - return 0; } |