[Python-checkins] closes bpo-31696: don't mention GCC in sys.version when building with clang (#3891)

Benjamin Peterson webhook-mailer at python.org
Fri Oct 6 00:15:17 EDT 2017


https://github.com/python/cpython/commit/7faf7e50757dde2cb8583ee08ef31f4b8312e44f
commit: 7faf7e50757dde2cb8583ee08ef31f4b8312e44f
branch: master
author: Benjamin Peterson <benjamin at python.org>
committer: GitHub <noreply at github.com>
date: 2017-10-05T21:15:14-07:00
summary:

closes bpo-31696: don't mention GCC in sys.version when building with clang (#3891)

files:
A Misc/NEWS.d/next/Build/2017-10-04-23-40-32.bpo-31696.Y3_aBV.rst
M Python/getcompiler.c

diff --git a/Misc/NEWS.d/next/Build/2017-10-04-23-40-32.bpo-31696.Y3_aBV.rst b/Misc/NEWS.d/next/Build/2017-10-04-23-40-32.bpo-31696.Y3_aBV.rst
new file mode 100644
index 00000000000..00aae0b8ae1
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2017-10-04-23-40-32.bpo-31696.Y3_aBV.rst
@@ -0,0 +1,2 @@
+Improve compiler version information in :data:`sys.version` when Python is
+built with Clang.
diff --git a/Python/getcompiler.c b/Python/getcompiler.c
index 9d9c33ac2de..59c0dbf92ae 100644
--- a/Python/getcompiler.c
+++ b/Python/getcompiler.c
@@ -5,15 +5,14 @@
 
 #ifndef COMPILER
 
-#ifdef __GNUC__
+// Note the __clang__ conditional has to come before the __GNUC__ one because
+// clang pretends to be GCC.
+#if defined(__clang__)
+#define COMPILER "\n[Clang " __clang_version__ "]"
+#elif defined(__GNUC__)
 #define COMPILER "\n[GCC " __VERSION__ "]"
-#endif
-
-#endif /* !COMPILER */
-
-#ifndef COMPILER
-
-#ifdef __cplusplus
+// Generic fallbacks.
+#elif defined(__cplusplus)
 #define COMPILER "[C++]"
 #else
 #define COMPILER "[C]"



More information about the Python-checkins mailing list