Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 426f2b4

Browse filesBrowse files
authored
bpo-1635741: Port _opcode module to multi-phase init (PEP 489) (GH-22050)
1 parent 1aaa21f commit 426f2b4
Copy full SHA for 426f2b4

File tree

2 files changed

+9
-14
lines changed
Filter options

2 files changed

+9
-14
lines changed
+2Lines 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

Copy file name to clipboardExpand all lines: Modules/_opcode.c
+7-14Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.