Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use PyInterpreterState_Get().
  • Loading branch information
ericsnowcurrently committed Feb 13, 2024
commit 7bd8f7f8b5d0d877c7a2b4ebc208a951467c1750
17 changes: 6 additions & 11 deletions Python/crossinterp.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "pycore_initconfig.h" // _PyStatus_OK()
#include "pycore_namespace.h" //_PyNamespace_New()
#include "pycore_pyerrors.h" // _PyErr_Clear()
#include "pycore_pystate.h" // _PyInterpreterState_GET()
#include "pycore_typeobject.h" // _PyType_GetModuleName()
#include "pycore_weakref.h" // _PyWeakref_GET_REF()

Expand Down Expand Up @@ -67,7 +66,7 @@ int
_Py_CallInInterpreter(PyInterpreterState *interp,
_Py_simple_func func, void *arg)
{
if (interp == _PyThreadState_GetCurrent()->interp) {
if (interp == PyInterpreterState_Get()) {
return func(arg);
}
// XXX Emit a warning if this fails?
Expand All @@ -79,7 +78,7 @@ int
_Py_CallInInterpreterAndRawFree(PyInterpreterState *interp,
_Py_simple_func func, void *arg)
{
if (interp == _PyThreadState_GetCurrent()->interp) {
if (interp == PyInterpreterState_Get()) {
int res = func(arg);
PyMem_RawFree(arg);
return res;
Expand Down Expand Up @@ -292,7 +291,7 @@ _set_xid_lookup_failure(PyInterpreterState *interp,
int
_PyObject_CheckCrossInterpreterData(PyObject *obj)
{
PyInterpreterState *interp = _PyInterpreterState_GET();
PyInterpreterState *interp = PyInterpreterState_Get();
crossinterpdatafunc getdata = lookup_getdata(interp, obj);
if (getdata == NULL) {
if (!PyErr_Occurred()) {
Expand All @@ -306,11 +305,7 @@ _PyObject_CheckCrossInterpreterData(PyObject *obj)
int
_PyObject_GetCrossInterpreterData(PyObject *obj, _PyCrossInterpreterData *data)
{
PyThreadState *tstate = _PyThreadState_GetCurrent();
#ifdef Py_DEBUG
// The caller must hold the GIL
_Py_EnsureTstateNotNULL(tstate);
#endif
PyThreadState *tstate = PyThreadState_Get();
PyInterpreterState *interp = tstate->interp;

// Reset data before re-populating.
Expand Down Expand Up @@ -1340,7 +1335,7 @@ _PyXI_FreeNamespace(_PyXI_namespace *ns)
return;
}

if (interpid == PyInterpreterState_GetID(_PyInterpreterState_GET())) {
if (interpid == PyInterpreterState_GetID(PyInterpreterState_Get())) {
_sharedns_free(ns);
}
else {
Expand Down Expand Up @@ -1539,7 +1534,7 @@ _propagate_not_shareable_error(_PyXI_session *session)
if (session == NULL) {
return;
}
PyInterpreterState *interp = _PyInterpreterState_GET();
PyInterpreterState *interp = PyInterpreterState_Get();
if (PyErr_ExceptionMatches(_get_not_shareable_error_type(interp))) {
// We want to propagate the exception directly.
session->_error_override = _PyXI_ERR_NOT_SHAREABLE;
Expand Down