gh-151483: Only declare `PyCodeObject._co_unique_id` on Free Threadin… · python/cpython@0cbac06

GitHub

Original file line numberDiff line numberDiff line change@@ -34,9 +34,13 @@ typedef struct {

3434char*entries[1];

3535} _PyCodeArray;

363637+#define_PyCode_DEF_UNIQUE_ID() \

38+ Py_ssize_t _co_unique_id; /* ID used for per-thread refcounting */

39+3740#define_PyCode_DEF_THREAD_LOCAL_BYTECODE() \

3841 _PyCodeArray *co_tlbc;

3942#else

43+#define_PyCode_DEF_UNIQUE_ID()

4044#define_PyCode_DEF_THREAD_LOCAL_BYTECODE()

4145#endif

4246@@ -101,7 +105,7 @@ typedef struct {

101105_PyCoCached*_co_cached; /* cached co_* attributes */ \

102106uintptr_t_co_instrumentation_version; /* current instrumentation version */ \

103107struct_PyCoMonitoringData*_co_monitoring; /* Monitoring data */ \

104-Py_ssize_t_co_unique_id;/* ID used for per-thread refcounting */ \

108+_PyCode_DEF_UNIQUE_ID() \

105109int_co_firsttraceable; /* index of first traceable instruction */ \

106110/* Scratch space for extra data relating to the code object. \

107111 Type is a void* to keep the format private in codeobject.c to force \