@@ -131,7 +131,23 @@ PyAPI_FUNC(void) _PyXIData_Clear(PyInterpreterState *, _PyXIData_t *);
131
131
132
132
/* getting cross-interpreter data */
133
133
134
- typedef int (* xidatafunc )(PyThreadState * tstate , PyObject * , _PyXIData_t * );
134
+ typedef int xidata_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
+ typedef int (* xidatafunc )(PyThreadState * , PyObject * , _PyXIData_t * );
145
+ typedef int (* xidatafbfunc )(
146
+ PyThreadState * , PyObject * , xidata_fallback_t , _PyXIData_t * );
147
+ typedef struct {
148
+ xidatafunc basic ;
149
+ xidatafbfunc fallback ;
150
+ } _PyXIData_getdata_t ;
135
151
136
152
PyAPI_FUNC (PyObject * ) _PyXIData_GetNotShareableErrorType (PyThreadState * );
137
153
PyAPI_FUNC (void ) _PyXIData_SetNotShareableError (PyThreadState * , const char * );
@@ -140,7 +156,7 @@ PyAPI_FUNC(void) _PyXIData_FormatNotShareableError(
140
156
const char * ,
141
157
...);
142
158
143
- PyAPI_FUNC (xidatafunc ) _PyXIData_Lookup (
159
+ PyAPI_FUNC (_PyXIData_getdata_t ) _PyXIData_Lookup (
144
160
PyThreadState * ,
145
161
PyObject * );
146
162
PyAPI_FUNC (int ) _PyObject_CheckXIData (
@@ -151,6 +167,11 @@ PyAPI_FUNC(int) _PyObject_GetXIData(
151
167
PyThreadState * ,
152
168
PyObject * ,
153
169
_PyXIData_t * );
170
+ PyAPI_FUNC (int ) _PyObject_GetXIDataWithFallback (
171
+ PyThreadState * ,
172
+ PyObject * ,
173
+ xidata_fallback_t ,
174
+ _PyXIData_t * );
154
175
155
176
// _PyObject_GetXIData() for bytes
156
177
typedef struct {
0 commit comments