]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.15] gh-150907: Fix dynamic_annotations.h when built with C++ and Valgrind (GH...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 5 Jun 2026 12:41:19 +0000 (14:41 +0200)
committerGitHub <noreply@github.com>
Fri, 5 Jun 2026 12:41:19 +0000 (12:41 +0000)
gh-150907: Fix dynamic_annotations.h when built with C++ and Valgrind (GH-150914)

Add extern "C++" scope for the C++ template.

Fix test_cppext when Python is built with --with-valgrind.
(cherry picked from commit c32501261aeeb0cc1ad1c53b6be9790ff1d23215)

Co-authored-by: Victor Stinner <vstinner@python.org>
Include/dynamic_annotations.h
Misc/NEWS.d/next/C_API/2026-06-04-14-26-17.gh-issue-150907.CA91_B.rst [new file with mode: 0644]

index 4d4def9bf8983e21209b598fc7cba728ca8c1d4c..5290319dd762c55c75c6ac595464cc4515632b41 100644 (file)
@@ -461,6 +461,7 @@ int RunningOnValgrind(void);
 
 #if DYNAMIC_ANNOTATIONS_ENABLED != 0 && defined(__cplusplus)
 
+extern "C++" {
   /* _Py_ANNOTATE_UNPROTECTED_READ is the preferred way to annotate racey reads.
 
      Instead of doing
@@ -476,6 +477,8 @@ int RunningOnValgrind(void);
     _Py_ANNOTATE_IGNORE_READS_END();
     return res;
   }
+}
+
   /* Apply _Py_ANNOTATE_BENIGN_RACE_SIZED to a static variable. */
 #define _Py_ANNOTATE_BENIGN_RACE_STATIC(static_var, description)        \
     namespace {                                                       \
diff --git a/Misc/NEWS.d/next/C_API/2026-06-04-14-26-17.gh-issue-150907.CA91_B.rst b/Misc/NEWS.d/next/C_API/2026-06-04-14-26-17.gh-issue-150907.CA91_B.rst
new file mode 100644 (file)
index 0000000..f58b248
--- /dev/null
@@ -0,0 +1,2 @@
+Fix ``dynamic_annotations.h`` header file when built with C++ and Valgrind:
+add ``extern "C++" scope`` for the C++ template. Patch by Victor Stinner.