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

Commit55ccaa0

Browse files
Add _PyObject_GetXIDataWithFallback().
1 parent8cf4947 commit55ccaa0

10 files changed

+572
-122
lines changed

‎Include/internal/pycore_crossinterp.h

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,23 @@ PyAPI_FUNC(void) _PyXIData_Clear(PyInterpreterState *, _PyXIData_t *);
131131

132132
/* getting cross-interpreter data */
133133

134-
typedefint (*xidatafunc)(PyThreadState*tstate,PyObject*,_PyXIData_t*);
134+
typedefintxidata_fallback_t;
135+
#define_PyXIDATA_XIDATA_ONLY (0)
136+
#define_PyXIDATA_FULL_FALLBACK (1)
137+
138+
// Technically, we don't need two different function types;
139+
// we could go with just the fallback one. However, only container
140+
// types like tuple need it, so always having the extra arg would be
141+
// a bit unfortunate. It's also nice to be able to clearly distinguish
142+
// between types that might call _PyObject_GetXIData() and those that won't.
143+
//
144+
typedefint (*xidatafunc)(PyThreadState*,PyObject*,_PyXIData_t*);
145+
typedefint (*xidatafbfunc)(
146+
PyThreadState*,PyObject*,xidata_fallback_t,_PyXIData_t*);
147+
typedefstruct {
148+
xidatafuncbasic;
149+
xidatafbfuncfallback;
150+
}_PyXIData_getdata_t;
135151

136152
PyAPI_FUNC(PyObject*)_PyXIData_GetNotShareableErrorType(PyThreadState*);
137153
PyAPI_FUNC(void)_PyXIData_SetNotShareableError(PyThreadState*,constchar*);
@@ -140,7 +156,7 @@ PyAPI_FUNC(void) _PyXIData_FormatNotShareableError(
140156
constchar*,
141157
...);
142158

143-
PyAPI_FUNC(xidatafunc)_PyXIData_Lookup(
159+
PyAPI_FUNC(_PyXIData_getdata_t)_PyXIData_Lookup(
144160
PyThreadState*,
145161
PyObject*);
146162
PyAPI_FUNC(int)_PyObject_CheckXIData(
@@ -151,6 +167,11 @@ PyAPI_FUNC(int) _PyObject_GetXIData(
151167
PyThreadState*,
152168
PyObject*,
153169
_PyXIData_t*);
170+
PyAPI_FUNC(int)_PyObject_GetXIDataWithFallback(
171+
PyThreadState*,
172+
PyObject*,
173+
xidata_fallback_t,
174+
_PyXIData_t*);
154175

155176
// _PyObject_GetXIData() for bytes
156177
typedefstruct {

‎Include/internal/pycore_crossinterp_data_registry.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ typedef struct _xid_regitem {
1717
/* This is NULL for builtin types. */
1818
PyObject*weakref;
1919
size_trefcount;
20-
xidatafuncgetdata;
20+
_PyXIData_getdata_tgetdata;
2121
}_PyXIData_regitem_t;
2222

2323
typedefstruct {
@@ -30,7 +30,7 @@ typedef struct {
3030
PyAPI_FUNC(int)_PyXIData_RegisterClass(
3131
PyThreadState*,
3232
PyTypeObject*,
33-
xidatafunc);
33+
_PyXIData_getdata_t);
3434
PyAPI_FUNC(int)_PyXIData_UnregisterClass(
3535
PyThreadState*,
3636
PyTypeObject*);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp