]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-151483: Only declare `PyCodeObject._co_unique_id` on Free Threading (#151484)
authorXiaowei Lu <lxw263044@alibaba-inc.com>
Mon, 29 Jun 2026 13:04:28 +0000 (21:04 +0800)
committerGitHub <noreply@github.com>
Mon, 29 Jun 2026 13:04:28 +0000 (15:04 +0200)
Include/cpython/code.h

index 84456a709a6abe7ec9934f5c3cf92593ff9b4722..1be47e42ed62bfb8b222a61412368c24e2397f0a 100644 (file)
@@ -34,9 +34,13 @@ typedef struct {
     char *entries[1];
 } _PyCodeArray;
 
+#define _PyCode_DEF_UNIQUE_ID() \
+    Py_ssize_t _co_unique_id;     /* ID used for per-thread refcounting */
+
 #define _PyCode_DEF_THREAD_LOCAL_BYTECODE() \
     _PyCodeArray *co_tlbc;
 #else
+#define _PyCode_DEF_UNIQUE_ID()
 #define _PyCode_DEF_THREAD_LOCAL_BYTECODE()
 #endif
 
@@ -101,7 +105,7 @@ typedef struct {
     _PyCoCached *_co_cached;      /* cached co_* attributes */                 \
     uintptr_t _co_instrumentation_version; /* current instrumentation version */ \
     struct _PyCoMonitoringData *_co_monitoring; /* Monitoring data */          \
-    Py_ssize_t _co_unique_id;     /* ID used for per-thread refcounting */   \
+    _PyCode_DEF_UNIQUE_ID()                                                    \
     int _co_firsttraceable;       /* index of first traceable instruction */   \
     /* Scratch space for extra data relating to the code object.               \
        Type is a void* to keep the format private in codeobject.c to force     \