https://github.com/python/cpython/commit/fd1b5c638ac6f632c5b67ab48ea22de96eb6f7d0
commit: fd1b5c638ac6f632c5b67ab48ea22de96eb6f7d0
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: vstinner <[email protected]>
date: 2026-06-05T12:29:28Z
summary:

[3.13] gh-150907: Fix dynamic_annotations.h when built with C++ and Valgrind 
(GH-150914) (#150964)

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 <[email protected]>

files:
A Misc/NEWS.d/next/C_API/2026-06-04-14-26-17.gh-issue-150907.CA91_B.rst
M Include/dynamic_annotations.h

diff --git a/Include/dynamic_annotations.h b/Include/dynamic_annotations.h
index 4d4def9bf8983e2..5290319dd762c55 100644
--- a/Include/dynamic_annotations.h
+++ b/Include/dynamic_annotations.h
@@ -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
index 000000000000000..f58b248f3a0b986
--- /dev/null
+++ b/Misc/NEWS.d/next/C_API/2026-06-04-14-26-17.gh-issue-150907.CA91_B.rst
@@ -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.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to