built on debug mode <debug-build>`.
(Contributed by Victor Stinner in :gh:`62948`.)
+opcode
+------
+
+* Move ``opcode.ENABLE_SPECIALIZATION`` to ``_opcode.ENABLE_SPECIALIZATION``.
+ This field was added in 3.12, it was never documented and is not intended for
+ external usage. (Contributed by Irit Katriel in :gh:`105481`.)
+
pathlib
-------
extern int _PyLineTable_NextAddressRange(PyCodeAddressRange *range);
extern int _PyLineTable_PreviousAddressRange(PyCodeAddressRange *range);
+#define ENABLE_SPECIALIZATION 1
+
/* Specialization functions */
extern void _Py_Specialize_LoadSuperAttr(PyObject *global_super, PyObject *cls,
#define NB_INPLACE_TRUE_DIVIDE 24
#define NB_INPLACE_XOR 25
-/* Defined in Lib/opcode.py */
-#define ENABLE_SPECIALIZATION 1
#ifdef __cplusplus
}
cmp_op = ('<', '<=', '==', '!=', '>', '>=')
-
-ENABLE_SPECIALIZATION = True
-
def is_pseudo(op):
return op >= MIN_PSEUDO_OPCODE and op <= MAX_PSEUDO_OPCODE
import contextlib
import functools
import getpass
-import opcode
+import _opcode
import os
import re
import stat
def requires_specialization(test):
return unittest.skipUnless(
- opcode.ENABLE_SPECIALIZATION, "requires specialization")(test)
+ _opcode.ENABLE_SPECIALIZATION, "requires specialization")(test)
def _filter_suite(suite, pred):
"""Recursively filter test cases in a suite based on a predicate."""
--- /dev/null
+:data:`opcode.ENABLE_SPECIALIZATION` (which was added in 3.12 but never documented or intended for external usage) is moved to :data:`_opcode.ENABLE_SPECIALIZATION` where tests can access it.
{NULL, NULL, 0, NULL}
};
+int
+_opcode_exec(PyObject *m) {
+ if (PyModule_AddIntMacro(m, ENABLE_SPECIALIZATION) < 0) {
+ return -1;
+ }
+ return 0;
+}
+
static PyModuleDef_Slot module_slots[] = {
+ {Py_mod_exec, _opcode_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};
opname = opcode['opname']
is_pseudo = opcode['is_pseudo']
- ENABLE_SPECIALIZATION = opcode["ENABLE_SPECIALIZATION"]
MIN_PSEUDO_OPCODE = opcode["MIN_PSEUDO_OPCODE"]
MAX_PSEUDO_OPCODE = opcode["MAX_PSEUDO_OPCODE"]
MIN_INSTRUMENTED_OPCODE = opcode["MIN_INSTRUMENTED_OPCODE"]
for i, (op, _) in enumerate(opcode["_nb_ops"]):
fobj.write(DEFINE.format(op, i))
- fobj.write("\n")
- fobj.write("/* Defined in Lib/opcode.py */\n")
- fobj.write(f"#define ENABLE_SPECIALIZATION {int(ENABLE_SPECIALIZATION)}")
-
iobj.write("\n")
iobj.write(f"\nextern const char *const _PyOpcode_OpName[{NUM_OPCODES}];\n")
iobj.write("\n#ifdef NEED_OPCODE_TABLES\n")