@@ -14,37 +14,6 @@ PyAPI_FUNC(Py_ssize_t) _Py_GetRefTotal(void);
14
14
#endif
15
15
16
16
17
- /********************* String Literals ****************************************/
18
- /* This structure helps managing static strings. The basic usage goes like this:
19
- Instead of doing
20
-
21
- r = PyObject_CallMethod(o, "foo", "args", ...);
22
-
23
- do
24
-
25
- _Py_IDENTIFIER(foo);
26
- ...
27
- r = _PyObject_CallMethodId(o, &PyId_foo, "args", ...);
28
-
29
- PyId_foo is a static variable, either on block level or file level. On first
30
- usage, the string "foo" is interned, and the structures are linked. On interpreter
31
- shutdown, all strings are released.
32
-
33
- Alternatively, _Py_static_string allows choosing the variable name.
34
- _PyUnicode_FromId returns a borrowed reference to the interned string.
35
- _PyObject_{Get,Set,Has}AttrId are __getattr__ versions using _Py_Identifier*.
36
- */
37
- typedef struct _Py_Identifier {
38
- const char * string ;
39
- // Index in PyInterpreterState.unicode.ids.array. It is process-wide
40
- // unique and must be initialized to -1.
41
- Py_ssize_t index ;
42
- } _Py_Identifier ;
43
-
44
- #define _Py_static_string_init (value ) { .string = value, .index = -1 }
45
- #define _Py_static_string (varname , value ) static _Py_Identifier varname = _Py_static_string_init(value)
46
- #define _Py_IDENTIFIER (varname ) _Py_static_string(PyId_##varname, #varname)
47
-
48
17
/* buffer interface */
49
18
typedef struct bufferinfo {
50
19
void * buf ;
@@ -299,24 +268,19 @@ typedef struct _heaptypeobject {
299
268
300
269
PyAPI_FUNC (const char * ) _PyType_Name (PyTypeObject * );
301
270
PyAPI_FUNC (PyObject * ) _PyType_Lookup (PyTypeObject * , PyObject * );
302
- PyAPI_FUNC (PyObject * ) _PyType_LookupId (PyTypeObject * , _Py_Identifier * );
303
271
PyAPI_FUNC (PyObject * ) _PyObject_LookupSpecial (PyObject * , PyObject * );
304
- PyAPI_FUNC (PyObject * ) _PyObject_LookupSpecialId (PyObject * , _Py_Identifier * );
305
272
PyAPI_FUNC (PyTypeObject * ) _PyType_CalculateMetaclass (PyTypeObject * , PyObject * );
306
273
PyAPI_FUNC (PyObject * ) _PyType_GetDocFromInternalDoc (const char * , const char * );
307
274
PyAPI_FUNC (PyObject * ) _PyType_GetTextSignatureFromInternalDoc (const char * , const char * );
308
275
struct PyModuleDef ;
309
276
PyAPI_FUNC (PyObject * ) _PyType_GetModuleByDef (PyTypeObject * , struct PyModuleDef * );
310
277
311
- struct _Py_Identifier ;
312
278
PyAPI_FUNC (int ) PyObject_Print (PyObject * , FILE * , int );
313
279
PyAPI_FUNC (void ) _Py_BreakPoint (void );
314
280
PyAPI_FUNC (void ) _PyObject_Dump (PyObject * );
315
281
PyAPI_FUNC (int ) _PyObject_IsFreed (PyObject * );
316
282
317
283
PyAPI_FUNC (int ) _PyObject_IsAbstract (PyObject * );
318
- PyAPI_FUNC (PyObject * ) _PyObject_GetAttrId (PyObject * , struct _Py_Identifier * );
319
- PyAPI_FUNC (int ) _PyObject_SetAttrId (PyObject * , struct _Py_Identifier * , PyObject * );
320
284
/* Replacements of PyObject_GetAttr() and _PyObject_GetAttrId() which
321
285
don't raise AttributeError.
322
286
@@ -327,7 +291,6 @@ PyAPI_FUNC(int) _PyObject_SetAttrId(PyObject *, struct _Py_Identifier *, PyObjec
327
291
is raised.
328
292
*/
329
293
PyAPI_FUNC (int ) _PyObject_LookupAttr (PyObject * , PyObject * , PyObject * * );
330
- PyAPI_FUNC (int ) _PyObject_LookupAttrId (PyObject * , struct _Py_Identifier * , PyObject * * );
331
294
332
295
PyAPI_FUNC (int ) _PyObject_GetMethod (PyObject * obj , PyObject * name , PyObject * * method );
333
296
@@ -346,6 +309,50 @@ _PyObject_GenericSetAttrWithDict(PyObject *, PyObject *,
346
309
347
310
PyAPI_FUNC (PyObject * ) _PyObject_FunctionStr (PyObject * );
348
311
312
+ /********************* String Literals ****************************************/
313
+ /* This structure helps managing static strings. The basic usage goes like this:
314
+ Instead of doing
315
+
316
+ r = PyObject_CallMethod(o, "foo", "args", ...);
317
+
318
+ do
319
+
320
+ _Py_IDENTIFIER(foo);
321
+ ...
322
+ r = _PyObject_CallMethodId(o, &PyId_foo, "args", ...);
323
+
324
+ PyId_foo is a static variable, either on block level or file level. On first
325
+ usage, the string "foo" is interned, and the structures are linked. On interpreter
326
+ shutdown, all strings are released.
327
+
328
+ Alternatively, _Py_static_string allows choosing the variable name.
329
+ _PyUnicode_FromId returns a borrowed reference to the interned string.
330
+ _PyObject_{Get,Set,Has}AttrId are __getattr__ versions using _Py_Identifier*.
331
+ */
332
+ typedef struct _Py_Identifier {
333
+ const char * string ;
334
+ // Index in PyInterpreterState.unicode.ids.array. It is process-wide
335
+ // unique and must be initialized to -1.
336
+ Py_ssize_t index ;
337
+ } _Py_Identifier ;
338
+
339
+ #if !defined(Py_BUILD_CORE ) || defined(Py_BUILD_CORE_MODULE )
340
+ // For now we are keeping _Py_IDENTIFIER for continued use
341
+ // in non-builtin extensions (and naughty PyPI modules).
342
+
343
+ #define _Py_static_string_init (value ) { .string = value, .index = -1 }
344
+ #define _Py_static_string (varname , value ) static _Py_Identifier varname = _Py_static_string_init(value)
345
+ #define _Py_IDENTIFIER (varname ) _Py_static_string(PyId_##varname, #varname)
346
+
347
+ #endif /* ! Py_BUILD_CORE */
348
+
349
+ PyAPI_FUNC (PyObject * ) _PyType_LookupId (PyTypeObject * , _Py_Identifier * );
350
+ PyAPI_FUNC (PyObject * ) _PyObject_LookupSpecialId (PyObject * , _Py_Identifier * );
351
+ struct _Py_Identifier ;
352
+ PyAPI_FUNC (PyObject * ) _PyObject_GetAttrId (PyObject * , struct _Py_Identifier * );
353
+ PyAPI_FUNC (int ) _PyObject_SetAttrId (PyObject * , struct _Py_Identifier * , PyObject * );
354
+ PyAPI_FUNC (int ) _PyObject_LookupAttrId (PyObject * , struct _Py_Identifier * , PyObject * * );
355
+
349
356
/* Safely decref `op` and set `op` to `op2`.
350
357
*
351
358
* As in case of Py_CLEAR "the obvious" code can be deadly:
0 commit comments