Skip to content

Commit 0cbac06

Browse files
authored
gh-151483: Only declare PyCodeObject._co_unique_id on Free Threading (#151484)
1 parent e7b21b6 commit 0cbac06

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

Include/cpython/code.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@ typedef struct {
3434
char *entries[1];
3535
} _PyCodeArray;
3636

37+
#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 */ \
102106
uintptr_t _co_instrumentation_version; /* current instrumentation version */ \
103107
struct _PyCoMonitoringData *_co_monitoring; /* Monitoring data */ \
104-
Py_ssize_t _co_unique_id; /* ID used for per-thread refcounting */ \
108+
_PyCode_DEF_UNIQUE_ID() \
105109
int _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 \

0 commit comments

Comments
 (0)