bpo-1635741: Port _opcode module to multi-phase init (PEP 489) (GH-22050)
This commit is contained in:
parent
1aaa21ff81
commit
426f2b4f13
|
@ -0,0 +1,2 @@
|
||||||
|
Port the :mod:`_opcode` extension module to multi-phase initialization
|
||||||
|
(:pep:`489`).
|
|
@ -36,9 +36,10 @@ _opcode_stack_effect_impl(PyObject *module, int opcode, PyObject *oparg,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
oparg_int = (int)PyLong_AsLong(oparg);
|
oparg_int = (int)PyLong_AsLong(oparg);
|
||||||
if ((oparg_int == -1) && PyErr_Occurred())
|
if ((oparg_int == -1) && PyErr_Occurred()) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (oparg != Py_None) {
|
else if (oparg != Py_None) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"stack_effect: opcode does not permit oparg but oparg was specified");
|
"stack_effect: opcode does not permit oparg but oparg was specified");
|
||||||
|
@ -67,30 +68,22 @@ _opcode_stack_effect_impl(PyObject *module, int opcode, PyObject *oparg,
|
||||||
return effect;
|
return effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static PyMethodDef
|
static PyMethodDef
|
||||||
opcode_functions[] = {
|
opcode_functions[] = {
|
||||||
_OPCODE_STACK_EFFECT_METHODDEF
|
_OPCODE_STACK_EFFECT_METHODDEF
|
||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static struct PyModuleDef opcodemodule = {
|
static struct PyModuleDef opcodemodule = {
|
||||||
PyModuleDef_HEAD_INIT,
|
PyModuleDef_HEAD_INIT,
|
||||||
"_opcode",
|
.m_name = "_opcode",
|
||||||
"Opcode support module.",
|
.m_doc = "Opcode support module.",
|
||||||
-1,
|
.m_size = 0,
|
||||||
opcode_functions,
|
.m_methods = opcode_functions
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
PyMODINIT_FUNC
|
||||||
PyInit__opcode(void)
|
PyInit__opcode(void)
|
||||||
{
|
{
|
||||||
return PyModule_Create(&opcodemodule);
|
return PyModuleDef_Init(&opcodemodule);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue