if (is_true < 0) {
return -1;
}
- if (is_true && !_Py_IsInterpreterFinalizing(PyInterpreterState_Get())) {
+ if (is_true && !_Py_IsInterpreterFinalizing(_PyInterpreterState_GET())) {
/* Only try to capture the traceback if the interpreter is not being
finalized. The original motivation to add a `_Py_IsFinalizing()`
call was to prevent SIGSEGV when a Future is created in a __del__
"reentrant call inside %R", self);
return 0;
}
- PyInterpreterState *interp = PyInterpreterState_Get();
+ PyInterpreterState *interp = _PyInterpreterState_GET();
relax_locking = _Py_IsInterpreterFinalizing(interp);
Py_BEGIN_ALLOW_THREADS
if (!relax_locking)
int *c_fds_to_keep = NULL;
Py_ssize_t fds_to_keep_len = PyTuple_GET_SIZE(py_fds_to_keep);
- PyInterpreterState *interp = PyInterpreterState_Get();
+ PyInterpreterState *interp = _PyInterpreterState_GET();
if ((preexec_fn != Py_None) && interp->finalizing) {
PyErr_SetString(PyExc_RuntimeError,
"preexec_fn not supported at interpreter shutdown");
set_eval_frame_default(PyObject *self, PyObject *Py_UNUSED(args))
{
module_state *state = get_module_state(self);
- _PyInterpreterState_SetEvalFrameFunc(PyInterpreterState_Get(), _PyEval_EvalFrameDefault);
+ _PyInterpreterState_SetEvalFrameFunc(_PyInterpreterState_GET(), _PyEval_EvalFrameDefault);
Py_CLEAR(state->record_list);
Py_RETURN_NONE;
}
return NULL;
}
Py_XSETREF(state->record_list, Py_NewRef(list));
- _PyInterpreterState_SetEvalFrameFunc(PyInterpreterState_Get(), record_eval);
+ _PyInterpreterState_SetEvalFrameFunc(_PyInterpreterState_GET(), record_eval);
Py_RETURN_NONE;
}
{
return NULL;
}
- PyInterpreterState *interp = PyInterpreterState_Get();
+ PyInterpreterState *interp = _PyInterpreterState_GET();
/* create the reference for the callbackwhile we hold the lock */
Py_INCREF(callable);
#endif
#include "Python.h"
-#include "internal/pycore_interp.h"
-#include "internal/pycore_typevarobject.h"
+#include "pycore_interp.h"
+#include "pycore_pystate.h" // _PyInterpreterState_GET()
+#include "pycore_typevarobject.h"
#include "clinic/_typingmodule.c.h"
/*[clinic input]
static int
_typing_exec(PyObject *m)
{
- PyInterpreterState *interp = PyInterpreterState_Get();
+ PyInterpreterState *interp = _PyInterpreterState_GET();
#define EXPORT_TYPE(name, typename) \
if (PyModule_AddObjectRef(m, name, \
#include "Python.h"
#include "pycore_moduleobject.h" // _PyModule_GetState()
+#include "pycore_pystate.h" // _PyInterpreterState_GET
#include "structmember.h" // PyMemberDef
{
/* The operation is no longer pending -- nothing to do. */
}
- else if (_Py_IsInterpreterFinalizing(PyInterpreterState_Get()))
+ else if (_Py_IsInterpreterFinalizing(_PyInterpreterState_GET()))
{
/* The operation is still pending -- give a warning. This
will probably only happen on Windows XP. */
// TypeVar, TypeVarTuple, and ParamSpec
#include "Python.h"
-#include "pycore_object.h" // _PyObject_GC_TRACK/UNTRACK
+#include "pycore_object.h" // _PyObject_GC_TRACK/UNTRACK
#include "pycore_typevarobject.h"
#include "pycore_unionobject.h" // _Py_union_type_or
#include "structmember.h"
contains_typevartuple(PyTupleObject *params)
{
Py_ssize_t n = PyTuple_GET_SIZE(params);
- PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.typevartuple_type;
+ PyTypeObject *tp = _PyInterpreterState_GET()->cached_objects.typevartuple_type;
for (Py_ssize_t i = 0; i < n; i++) {
PyObject *param = PyTuple_GET_ITEM(params, i);
if (Py_IS_TYPE(param, tp)) {
if (new_params == NULL) {
return NULL;
}
- PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.typevartuple_type;
+ PyTypeObject *tp = _PyInterpreterState_GET()->cached_objects.typevartuple_type;
for (Py_ssize_t i = 0; i < n; i++) {
PyObject *param = PyTuple_GET_ITEM(params, i);
if (Py_IS_TYPE(param, tp)) {
bool covariant, bool contravariant, bool infer_variance,
PyObject *module)
{
- PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.typevar_type;
+ PyTypeObject *tp = _PyInterpreterState_GET()->cached_objects.typevar_type;
assert(tp != NULL);
typevarobject *tv = PyObject_GC_New(typevarobject, tp);
if (tv == NULL) {
{
paramspecattrobject *psa = (paramspecattrobject *)self;
- PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.paramspec_type;
+ PyTypeObject *tp = _PyInterpreterState_GET()->cached_objects.paramspec_type;
if (Py_IS_TYPE(psa->__origin__, tp)) {
return PyUnicode_FromFormat("%U.args",
((paramspecobject *)psa->__origin__)->name);
{
paramspecattrobject *psk = (paramspecattrobject *)self;
- PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.paramspec_type;
+ PyTypeObject *tp = _PyInterpreterState_GET()->cached_objects.paramspec_type;
if (Py_IS_TYPE(psk->__origin__, tp)) {
return PyUnicode_FromFormat("%U.kwargs",
((paramspecobject *)psk->__origin__)->name);
static PyObject *
paramspec_args(PyObject *self, void *unused)
{
- PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.paramspecargs_type;
+ PyTypeObject *tp = _PyInterpreterState_GET()->cached_objects.paramspecargs_type;
return (PyObject *)paramspecattr_new(tp, self);
}
static PyObject *
paramspec_kwargs(PyObject *self, void *unused)
{
- PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.paramspeckwargs_type;
+ PyTypeObject *tp = _PyInterpreterState_GET()->cached_objects.paramspeckwargs_type;
return (PyObject *)paramspecattr_new(tp, self);
}
paramspec_alloc(PyObject *name, PyObject *bound, bool covariant,
bool contravariant, bool infer_variance, PyObject *module)
{
- PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.paramspec_type;
+ PyTypeObject *tp = _PyInterpreterState_GET()->cached_objects.paramspec_type;
paramspecobject *ps = PyObject_GC_New(paramspecobject, tp);
if (ps == NULL) {
return NULL;
static typevartupleobject *
typevartuple_alloc(PyObject *name, PyObject *module)
{
- PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.typevartuple_type;
+ PyTypeObject *tp = _PyInterpreterState_GET()->cached_objects.typevartuple_type;
typevartupleobject *tvt = PyObject_GC_New(typevartupleobject, tp);
if (tvt == NULL) {
return NULL;
{
params = unpack_typevartuples(params);
- PyInterpreterState *interp = PyInterpreterState_Get();
+ PyInterpreterState *interp = _PyInterpreterState_GET();
if (interp->cached_objects.generic_type == NULL) {
PyErr_SetString(PyExc_SystemError, "Cannot find Generic type");
return NULL;
#include "Python.h"
#include "pycore_call.h" // _PyObject_CallNoArgs()
#include "pycore_interp.h" // PyInterpreterState.codec_search_path
-#include "pycore_pyerrors.h" // _PyErr_FormatNote()
+#include "pycore_pyerrors.h" // _PyErr_FormatNote()
#include "pycore_pystate.h" // _PyInterpreterState_GET()
#include "pycore_ucnhash.h" // _PyUnicode_Name_CAPI
#include <ctype.h>
int
PyCodec_Unregister(PyObject *search_function)
{
- PyInterpreterState *interp = PyInterpreterState_Get();
+ PyInterpreterState *interp = _PyInterpreterState_GET();
PyObject *codec_search_path = interp->codec_search_path;
/* Do nothing if codec_search_path is not created yet or was cleared. */
if (codec_search_path == NULL) {
-
-
#include "Python.h"
#include "pycore_call.h"
#include "pycore_frame.h"
#include "pycore_object.h"
#include "pycore_opcode.h"
#include "pycore_pyerrors.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h" // _PyInterpreterState_GET()
/* Uncomment this to dump debugging output when assertions fail */
// #define INSTRUMENT_DEBUG 1
fprintf(out, "NULL\n");
return;
}
- dump_monitors("Global", PyInterpreterState_Get()->monitors, out);
+ dump_monitors("Global", _PyInterpreterState_GET()->monitors, out);
dump_monitors("Code", data->local_monitors, out);
dump_monitors("Active", data->active_monitors, out);
int code_len = (int)Py_SIZE(code);
if (data == NULL) {
return;
}
- _Py_Monitors active_monitors = PyInterpreterState_Get()->monitors;
+ _Py_Monitors active_monitors = _PyInterpreterState_GET()->monitors;
if (code->_co_monitoring) {
_Py_Monitors local_monitors = code->_co_monitoring->local_monitors;
active_monitors = monitors_or(active_monitors, local_monitors);
static bool
tools_is_subset_for_event(PyCodeObject * code, int event, int tools)
{
- int global_tools = PyInterpreterState_Get()->monitors.tools[event];
+ int global_tools = _PyInterpreterState_GET()->monitors.tools[event];
int local_tools = code->_co_monitoring->local_monitors.tools[event];
return tools == ((global_tools | local_tools) & tools);
}
-
#include "Python.h"
#include "opcode.h"
#include "pycore_interp.h"
#include "pycore_opcode.h"
#include "opcode_metadata.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h" // _PyInterpreterState_GET()
#include "pycore_uops.h"
#include "cpython/optimizer.h"
#include <stdbool.h>
_PyOptimizerObject *
PyUnstable_GetOptimizer(void)
{
- PyInterpreterState *interp = PyInterpreterState_Get();
+ PyInterpreterState *interp = _PyInterpreterState_GET();
if (interp->optimizer == &_PyOptimizer_Default) {
return NULL;
}
void
PyUnstable_SetOptimizer(_PyOptimizerObject *optimizer)
{
- PyInterpreterState *interp = PyInterpreterState_Get();
+ PyInterpreterState *interp = _PyInterpreterState_GET();
if (optimizer == NULL) {
optimizer = &_PyOptimizer_Default;
}
{
PyCodeObject *code = (PyCodeObject *)frame->f_executable;
assert(PyCode_Check(code));
- PyInterpreterState *interp = PyInterpreterState_Get();
+ PyInterpreterState *interp = _PyInterpreterState_GET();
if (!has_space_for_executor(code, src)) {
goto jump_to_destination;
}
int
_PyInterpreterState_GetConfigCopy(PyConfig *config)
{
- PyInterpreterState *interp = PyInterpreterState_Get();
+ PyInterpreterState *interp = _PyInterpreterState_GET();
PyStatus status = _PyConfig_Copy(config, &interp->config);
if (PyStatus_Exception(status)) {