[Python-checkins] bpo-1635741: Port _opcode module to multi-phase init (PEP 489) (GH-22050)

Mohamed Koubaa webhook-mailer at python.org
Mon Sep 7 04:49:07 EDT 2020


https://github.com/python/cpython/commit/426f2b4f13f392875e7861dbd7f34735731eff17
commit: 426f2b4f13f392875e7861dbd7f34735731eff17
branch: master
author: Mohamed Koubaa <koubaa.m at gmail.com>
committer: GitHub <noreply at github.com>
date: 2020-09-07T10:48:44+02:00
summary:

bpo-1635741: Port _opcode module to multi-phase init (PEP 489) (GH-22050)

files:
A Misc/NEWS.d/next/Core and Builtins/2020-09-01-17-06-02.bpo-1635741.5jZymK.rst
M Modules/_opcode.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-09-01-17-06-02.bpo-1635741.5jZymK.rst b/Misc/NEWS.d/next/Core and Builtins/2020-09-01-17-06-02.bpo-1635741.5jZymK.rst
new file mode 100644
index 0000000000000..c3bc9a78a2e05
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2020-09-01-17-06-02.bpo-1635741.5jZymK.rst	
@@ -0,0 +1,2 @@
+Port the :mod:`_opcode` extension module to multi-phase initialization
+(:pep:`489`).
diff --git a/Modules/_opcode.c b/Modules/_opcode.c
index 42a8732694afe..d8de0762e765a 100644
--- a/Modules/_opcode.c
+++ b/Modules/_opcode.c
@@ -36,8 +36,9 @@ _opcode_stack_effect_impl(PyObject *module, int opcode, PyObject *oparg,
             return -1;
         }
         oparg_int = (int)PyLong_AsLong(oparg);
-        if ((oparg_int == -1) && PyErr_Occurred())
+        if ((oparg_int == -1) && PyErr_Occurred()) {
             return -1;
+        }
     }
     else if (oparg != Py_None) {
         PyErr_SetString(PyExc_ValueError,
@@ -67,30 +68,22 @@ _opcode_stack_effect_impl(PyObject *module, int opcode, PyObject *oparg,
     return effect;
 }
 
-
-
-
 static PyMethodDef
 opcode_functions[] =  {
     _OPCODE_STACK_EFFECT_METHODDEF
     {NULL, NULL, 0, NULL}
 };
 
-
 static struct PyModuleDef opcodemodule = {
     PyModuleDef_HEAD_INIT,
-    "_opcode",
-    "Opcode support module.",
-    -1,
-    opcode_functions,
-    NULL,
-    NULL,
-    NULL,
-    NULL
+    .m_name = "_opcode",
+    .m_doc = "Opcode support module.",
+    .m_size = 0,
+    .m_methods = opcode_functions
 };
 
 PyMODINIT_FUNC
 PyInit__opcode(void)
 {
-    return PyModule_Create(&opcodemodule);
+    return PyModuleDef_Init(&opcodemodule);
 }



More information about the Python-checkins mailing list