Skip to content

Commit 13e530a

Browse files
koubaaSeth Sims
authored and
Seth Sims
committed
bpo-1635741: Port _opcode module to multi-phase init (PEP 489) (pythonGH-22050)
1 parent 0be5f5f commit 13e530a

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Port the :mod:`_opcode` extension module to multi-phase initialization
2+
(:pep:`489`).

Modules/_opcode.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ _opcode_stack_effect_impl(PyObject *module, int opcode, PyObject *oparg,
3636
return -1;
3737
}
3838
oparg_int = (int)PyLong_AsLong(oparg);
39-
if ((oparg_int == -1) && PyErr_Occurred())
39+
if ((oparg_int == -1) && PyErr_Occurred()) {
4040
return -1;
41+
}
4142
}
4243
else if (oparg != Py_None) {
4344
PyErr_SetString(PyExc_ValueError,
@@ -67,30 +68,22 @@ _opcode_stack_effect_impl(PyObject *module, int opcode, PyObject *oparg,
6768
return effect;
6869
}
6970

70-
71-
72-
7371
static PyMethodDef
7472
opcode_functions[] = {
7573
_OPCODE_STACK_EFFECT_METHODDEF
7674
{NULL, NULL, 0, NULL}
7775
};
7876

79-
8077
static struct PyModuleDef opcodemodule = {
8178
PyModuleDef_HEAD_INIT,
82-
"_opcode",
83-
"Opcode support module.",
84-
-1,
85-
opcode_functions,
86-
NULL,
87-
NULL,
88-
NULL,
89-
NULL
79+
.m_name = "_opcode",
80+
.m_doc = "Opcode support module.",
81+
.m_size = 0,
82+
.m_methods = opcode_functions
9083
};
9184

9285
PyMODINIT_FUNC
9386
PyInit__opcode(void)
9487
{
95-
return PyModule_Create(&opcodemodule);
88+
return PyModuleDef_Init(&opcodemodule);
9689
}

0 commit comments

Comments
 (0)