Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

gh-132775: Cleanup Related to crossinterp.c Before Further Changes#132974

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
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
NextNext commit
Clean up crossinterp.c.
  • Loading branch information
@ericsnowcurrently
ericsnowcurrently committedApr 25, 2025
commit28c9edaaf38c3104de1c4c06895ae834644cf604
66 changes: 33 additions & 33 deletionsInclude/internal/pycore_crossinterp.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -57,7 +57,7 @@ struct _xidata {
// likely a registered "xidatafunc", is responsible for
// ensuring it owns the reference (i.e. incref).
PyObject *obj;
//interp is the ID of the owning interpreter of the original
//interpid is the ID of the owning interpreter of the original
// object. It corresponds to the active interpreter when
// _PyObject_GetXIData() was called. This should only
// be set by the cross-interpreter machinery.
Expand DownExpand Up@@ -93,37 +93,6 @@ PyAPI_FUNC(void) _PyXIData_Free(_PyXIData_t *data);
// Users should not need getters for "new_object" or "free".


/* getting cross-interpreter data */

typedef int (*xidatafunc)(PyThreadState *tstate, PyObject *, _PyXIData_t *);

PyAPI_FUNC(PyObject *) _PyXIData_GetNotShareableErrorType(PyThreadState *);
PyAPI_FUNC(void) _PyXIData_SetNotShareableError(PyThreadState *, const char *);
PyAPI_FUNC(void) _PyXIData_FormatNotShareableError(
PyThreadState *,
const char *,
...);

PyAPI_FUNC(xidatafunc) _PyXIData_Lookup(
PyThreadState *,
PyObject *);
PyAPI_FUNC(int) _PyObject_CheckXIData(
PyThreadState *,
PyObject *);

PyAPI_FUNC(int) _PyObject_GetXIData(
PyThreadState *,
PyObject *,
_PyXIData_t *);


/* using cross-interpreter data */

PyAPI_FUNC(PyObject *) _PyXIData_NewObject(_PyXIData_t *);
PyAPI_FUNC(int) _PyXIData_Release(_PyXIData_t *);
PyAPI_FUNC(int) _PyXIData_ReleaseAndRawFree(_PyXIData_t *);


/* defining cross-interpreter data */

PyAPI_FUNC(void) _PyXIData_Init(
Expand All@@ -134,7 +103,7 @@ PyAPI_FUNC(int) _PyXIData_InitWithSize(
_PyXIData_t *,
PyInterpreterState *interp, const size_t, PyObject *,
xid_newobjfunc);
PyAPI_FUNC(void) _PyXIData_Clear(PyInterpreterState *, _PyXIData_t *);
PyAPI_FUNC(void) _PyXIData_Clear(PyInterpreterState *, _PyXIData_t *);

// Normally the Init* functions are sufficient. The only time
// additional initialization might be needed is to set the "free" func,
Expand All@@ -156,6 +125,37 @@ PyAPI_FUNC(void) _PyXIData_Clear( PyInterpreterState *, _PyXIData_t *);
} while (0)


/* getting cross-interpreter data */

typedef int (*xidatafunc)(PyThreadState *tstate, PyObject *, _PyXIData_t *);

PyAPI_FUNC(PyObject *) _PyXIData_GetNotShareableErrorType(PyThreadState *);
PyAPI_FUNC(void) _PyXIData_SetNotShareableError(PyThreadState *, const char *);
PyAPI_FUNC(void) _PyXIData_FormatNotShareableError(
PyThreadState *,
const char *,
...);

PyAPI_FUNC(xidatafunc) _PyXIData_Lookup(
PyThreadState *,
PyObject *);
PyAPI_FUNC(int) _PyObject_CheckXIData(
PyThreadState *,
PyObject *);

PyAPI_FUNC(int) _PyObject_GetXIData(
PyThreadState *,
PyObject *,
_PyXIData_t *);


/* using cross-interpreter data */

PyAPI_FUNC(PyObject *) _PyXIData_NewObject(_PyXIData_t *);
PyAPI_FUNC(int) _PyXIData_Release(_PyXIData_t *);
PyAPI_FUNC(int) _PyXIData_ReleaseAndRawFree(_PyXIData_t *);


/* cross-interpreter data registry */

#define Py_CORE_CROSSINTERP_DATA_REGISTRY_H
Expand Down
2 changes: 1 addition & 1 deletionModules/_interpchannelsmodule.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1774,7 +1774,7 @@ channel_send(_channels *channels, int64_t cid, PyObject *obj,
}

// Convert the object to cross-interpreter data.
_PyXIData_t *data =GLOBAL_MALLOC(_PyXIData_t);
_PyXIData_t *data =_PyXIData_New();
if (data == NULL) {
PyThread_release_lock(mutex);
return -1;
Expand Down
2 changes: 1 addition & 1 deletionModules/_interpqueuesmodule.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1138,7 +1138,7 @@ queue_put(_queues *queues, int64_t qid, PyObject *obj, int fmt, int unboundop)
assert(queue != NULL);

// Convert the object to cross-interpreter data.
_PyXIData_t *data =GLOBAL_MALLOC(_PyXIData_t);
_PyXIData_t *data =_PyXIData_New();
if (data == NULL) {
_queue_unmark_waiter(queue, queues->mutex);
return -1;
Expand Down
28 changes: 14 additions & 14 deletionsModules/_testinternalcapi.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1686,10 +1686,10 @@ interpreter_refcount_linked(PyObject *self, PyObject *idobj)
static void
_xid_capsule_destructor(PyObject *capsule)
{
_PyXIData_t *data = (_PyXIData_t *)PyCapsule_GetPointer(capsule, NULL);
if (data != NULL) {
assert(_PyXIData_Release(data) == 0);
_PyXIData_Free(data);
_PyXIData_t *xidata = (_PyXIData_t *)PyCapsule_GetPointer(capsule, NULL);
if (xidata != NULL) {
assert(_PyXIData_Release(xidata) == 0);
_PyXIData_Free(xidata);
}
}

Expand All@@ -1703,18 +1703,18 @@ get_crossinterp_data(PyObject *self, PyObject *args)
return NULL;
}

_PyXIData_t *data = _PyXIData_New();
if (data == NULL) {
_PyXIData_t *xidata = _PyXIData_New();
if (xidata == NULL) {
return NULL;
}
if (_PyObject_GetXIData(tstate, obj,data) != 0) {
_PyXIData_Free(data);
if (_PyObject_GetXIData(tstate, obj,xidata) != 0) {
_PyXIData_Free(xidata);
return NULL;
}
PyObject *capsule = PyCapsule_New(data, NULL, _xid_capsule_destructor);
PyObject *capsule = PyCapsule_New(xidata, NULL, _xid_capsule_destructor);
if (capsule == NULL) {
assert(_PyXIData_Release(data) == 0);
_PyXIData_Free(data);
assert(_PyXIData_Release(xidata) == 0);
_PyXIData_Free(xidata);
}
return capsule;
}
Expand All@@ -1727,11 +1727,11 @@ restore_crossinterp_data(PyObject *self, PyObject *args)
return NULL;
}

_PyXIData_t *data = (_PyXIData_t *)PyCapsule_GetPointer(capsule, NULL);
if (data == NULL) {
_PyXIData_t *xidata = (_PyXIData_t *)PyCapsule_GetPointer(capsule, NULL);
if (xidata == NULL) {
return NULL;
}
return _PyXIData_NewObject(data);
return _PyXIData_NewObject(xidata);
}


Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp