Repository navigation
Conversation
Change also PyType_GetFlags() return type to uint64_t. Add _PyType_GetFlags64() and expose it as PyType_GetFlags() with a macro. Keep the existing PyType_GetFlags() function unchanged (return unsigned long) for the stable ABI. PyType_HasFeature() now calls _PyType_GetFlags64() on the limited C API 3.16 or newer, or calls PyType_GetFlags() on the limited C API 3.15 and older. PyType_Spec.flags type stays as unsigned long, since the structure is part of the stable ABI. Use PyType_FromSlots() if you need 64-bit flags.
|
cc @encukou |
Documentation build overview
5 files changed ·
|
Fix support.calcobjsize(): use "0Q" alignement if the format contains "Q" (unsigned long).
|
I'm not sure how debuggers/profilers are supposed to deal with - if ((GET_MEMBER(unsigned long, type_obj, unwinder->debug_offsets.type_object.tp_flags) & Py_TPFLAGS_LONG_SUBCLASS)) {
+ if ((GET_MEMBER(uint64_t, type_obj, unwinder->debug_offsets.type_object.tp_flags) & Py_TPFLAGS_LONG_SUBCLASS)) { |
| per-type. It still returns the current version tag. | ||
|
|
||
| .. c:function:: unsigned long PyType_GetFlags(PyTypeObject* type) | ||
| .. c:function:: uint64_t PyType_GetFlags(PyTypeObject* type) |
There was a problem hiding this comment.
This function is in the stable ABI, this change is an ABI change on 32-bit platforms and 64-bit windows.
There was a problem hiding this comment.
Ah, I should maybe elaborate the documentation. The unsigned long PyType_GetFlags(PyTypeObject* type) function remains unchanged with my change, it still returns unsigned long. What changes is the PyType_GetFlags "API": when you write PyType_GetFlags() in your code, in fact, _PyType_GetFlags64() will be called at the ABI level, and _PyType_GetFlags64() return value is uint64_t.
This replacement trick is only done if you don't use use the limited C API or if you target the limited C API 3.16 or newer.
In practice:
PyAPI_FUNC(unsigned long) PyType_GetFlags(PyTypeObject*);
PyAPI_FUNC(uint64_t) _PyType_GetFlags64(PyTypeObject*);
#if !defined(Py_LIMITED_API) || Py_LIMITED_API >= _Py_PACK_VERSION(3, 16)
# define PyType_GetFlags _PyType_GetFlags64
#endifThere was a problem hiding this comment.
I updated the doc. Does it make sense to you?
Change also PyType_GetFlags() return type to uint64_t. Add _PyType_GetFlags64() and expose it as PyType_GetFlags() with a macro. Keep the existing PyType_GetFlags() function unchanged (return unsigned long) for the stable ABI.
PyType_HasFeature() now calls _PyType_GetFlags64() on the limited C API 3.16 or newer, or calls PyType_GetFlags() on the limited C API 3.15 and older.
PyType_Spec.flags type stays as unsigned long, since the structure is part of the stable ABI. Use PyType_FromSlots() if you need 64-bit flags.
PyTypeObject.tp_flagstype touint64_t#161562