Skip to content

Commit dc6d476

Browse files
committed
Strip '[ and ']' from COMPILER and _Py_COMPILER
1 parent 11cd830 commit dc6d476

3 files changed

Lines changed: 18 additions & 17 deletions

File tree

‎PC/pyconfig.h‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ WIN32 is still required for the locale module.
123123
* on macro arguments, and doesn't evaluate macros passed *as* arguments.
124124
*/
125125
#define _Py_PASTE_VERSION(SUFFIX) \
126-
("[MSC v." _Py_STRINGIZE(_MSC_VER) " " SUFFIX "]")
126+
("MSC v." _Py_STRINGIZE(_MSC_VER) " " SUFFIX "")
127127
/* e.g., this produces, after compile-time string catenation,
128-
* ("[MSC v.1900 64 bit (Intel)]")
128+
* ("MSC v.1900 64 bit (Intel)")
129129
*
130130
* _Py_STRINGIZE(_MSC_VER) expands to
131131
* _Py_STRINGIZE1(_MSC_VER) and this second macro call is scanned
@@ -150,9 +150,9 @@ WIN32 is still required for the locale module.
150150

151151
#ifdef __clang__
152152
#define _Py_CLANG_COMPILER(platform) ( \
153-
"[Clang " _Py_STRINGIZE(__clang_major__) "." _Py_STRINGIZE(__clang_minor__) \
153+
"Clang " _Py_STRINGIZE(__clang_major__) "." _Py_STRINGIZE(__clang_minor__) \
154154
"." _Py_STRINGIZE(__clang_patchlevel__) " " platform \
155-
" with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
155+
" with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT")
156156
#endif
157157

158158
/* set the _Py_COMPILER and support tier
@@ -168,7 +168,7 @@ WIN32 is still required for the locale module.
168168
#define _Py_COMPILER _Py_CLANG_COMPILER("64 bit (AMD64)")
169169
#define PY_SUPPORT_TIER 0
170170
#elif defined(__INTEL_COMPILER)
171-
#define _Py_COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 64 bit (amd64) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
171+
#define _Py_COMPILER ("ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 64 bit (amd64) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT")
172172
#define PY_SUPPORT_TIER 0
173173
#else
174174
#define _Py_COMPILER _Py_PASTE_VERSION("64 bit (AMD64)")
@@ -235,7 +235,7 @@ typedef _W64 int Py_ssize_t;
235235
#define _Py_COMPILER _Py_CLANG_COMPILER("32 bit (Intel)")
236236
#define PY_SUPPORT_TIER 0
237237
#elif defined(__INTEL_COMPILER)
238-
#define _Py_COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 32 bit (Intel) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
238+
#define _Py_COMPILER ("ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 32 bit (Intel) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT")
239239
#define PY_SUPPORT_TIER 0
240240
#else
241241
#define _Py_COMPILER _Py_PASTE_VERSION("32 bit (Intel)")
@@ -285,7 +285,7 @@ typedef int pid_t;
285285
#warning "Please use an up-to-date version of gcc! (>2.91 recommended)"
286286
#endif
287287

288-
#define _Py_COMPILER "[gcc]"
288+
#define _Py_COMPILER "gcc"
289289
#define PY_LONG_LONG long long
290290
#define PY_LLONG_MIN LLONG_MIN
291291
#define PY_LLONG_MAX LLONG_MAX
@@ -298,7 +298,7 @@ typedef int pid_t;
298298
/* XXX These defines are likely incomplete, but should be easy to fix.
299299
They should be complete enough to build extension modules. */
300300

301-
#define _Py_COMPILER "[lcc-win32]"
301+
#define _Py_COMPILER "lcc-win32"
302302
typedef int pid_t;
303303
/* __declspec() is supported here too - do nothing to get the defaults */
304304

‎Programs/_getcompiler.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,21 @@
1414
// Note the __clang__ conditional has to come before the __GNUC__ one because
1515
// clang pretends to be GCC.
1616
#if defined(__clang__)
17-
# define COMPILER "[Clang " __clang_version__ "]"
17+
# define COMPILER "Clang " __clang_version__
1818
#elif defined(__GNUC__)
19-
# define COMPILER "[GCC " __VERSION__ "]"
19+
# define COMPILER "GCC " __VERSION__
2020
// Generic fallbacks.
2121
#elif defined(__cplusplus)
22-
# define COMPILER "[C++]"
22+
# define COMPILER "C++"
2323
#else
24-
# define COMPILER "[C]"
24+
# define COMPILER "C"
2525
#endif
2626

2727
#endif /* !COMPILER */
2828

2929
int main()
3030
{
31+
return 1;
3132
const char *compiler = COMPILER;
3233
printf("%s\n", compiler);
3334
return 0;

‎Tools/build/generate_getbuildinfo.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ def get_compiler():
148148

149149
cmd = shlex.split(CC)
150150
output = run_command([*cmd, '--version'])
151-
output = output.splitlines()[0]
152-
return f'[{output}]'
151+
# Get the first line
152+
return output.splitlines()[0]
153153

154154

155155
def main():
@@ -188,9 +188,9 @@ def main():
188188
free_threading = get_gil_disable()
189189

190190
if free_threading:
191-
version = f"{PY_VERSION} free-threading build ({build_info}) {compiler}"
191+
version = f"{PY_VERSION} free-threading build ({build_info}) [{compiler}]"
192192
else:
193-
version = f"{PY_VERSION} ({build_info}) {compiler}"
193+
version = f"{PY_VERSION} ({build_info}) [{compiler}]"
194194

195195
new_filename = output_filename + ".new"
196196
with open(new_filename, "w", encoding="utf8") as fp:
@@ -200,7 +200,7 @@ def write_macro(name, value):
200200
print(f'// Header file auto-generated by {SCRIPT_FULLNAME}', file=fp)
201201
print(file=fp)
202202
write_macro('PLATFORM', platform)
203-
write_macro('COMPILER', compiler)
203+
write_macro('COMPILER', f'[{compiler}]')
204204
write_macro('GIT_VERSION', git_version)
205205
write_macro('GIT_IDENTIFIER', git_id)
206206
write_macro('BUILD_INFO', build_info)

0 commit comments

Comments
 (0)