8000 gh-76785: Improved Subinterpreters Compatibility with 3.12 by ericsnowcurrently · Pull Request #115424 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-76785: Improved Subinterpreters Compatibility with 3.12 #115424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
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
Factor out _interpreters_common.h.
  • Loading branch information
ericsnowcurrently committed Feb 13, 2024
commit e5fcc75afbbebc2a26cb604deff7a8921a7fa7e8
7 changes: 7 additions & 0 deletions Modules/_interpreters_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

static int
ensure_xid_class(PyTypeObject *cls, crossinterpdatafunc getdata)
{
//assert(cls->tp_flags & Py_TPFLAGS_HEAPTYPE);
return _PyCrossInterpreterData_RegisterClass(cls, getdata);
}
4 changes: 3 additions & 1 deletion Modules/_xxinterpchannelsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <sched.h> // sched_yield()
#endif

#include "_interpreters_common.h"


/*
This module has the following process-global state:
Expand Down Expand Up @@ -101,7 +103,7 @@ static int
register_xid_class(PyTypeObject *cls, crossinterpdatafunc shared,
struct xid_class_registry *classes)
{
int res = _PyCrossInterpreterData_RegisterClass(cls, shared);
int res = ensure_xid_class(cls, shared);
if (res == 0) {
assert(classes->count < MAX_XID_CLASSES);
// The class has refs elsewhere, so we need to incref here.
Expand Down
4 changes: 3 additions & 1 deletion Modules/_xxinterpqueuesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "Python.h"
#include "pycore_crossinterp.h" // struct _xid

#include "_interpreters_common.h"


#define MODULE_NAME "_xxinterpqueues"

Expand Down Expand Up @@ -1062,7 +1064,7 @@ set_external_queue_type(PyObject *module, PyTypeObject *queue_type)
}
state->queue_type = (PyTypeObject *)Py_NewRef(queue_type);

if (_PyCrossInterpreterData_RegisterClass(queue_type, _queueobj_shared) < 0) {
if (ensure_xid_class(queue_type, _queueobj_shared) < 0) {
return -1;
}

Expand Down
5 changes: 3 additions & 2 deletions Modules/_xxsubinterpretersmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "interpreteridobject.h"
#include "marshal.h" // PyMarshal_ReadObjectFromString()

#include "_interpreters_common.h"


#define MODULE_NAME "_xxsubinterpreters"

Expand Down Expand Up @@ -267,8 +269,7 @@ register_memoryview_xid(PyObject *mod, PyTypeObject **p_state)
*p_state = cls;

// Register XID for the builtin memoryview type.
if (_PyCrossInterpreterData_RegisterClass(
&PyMemoryView_Type, _memoryview_shared) < 0) {
if (ensure_xid_class(&PyMemoryView_Type, _memoryview_shared) < 0) {
return -1;
}
// We don't ever bother un-registering memoryview.
Expand Down
0