[Python-checkins] Fix c-analyzer for GCC: ignore LANG env var (#106173)

vstinner webhook-mailer at python.org
Tue Jun 27 22:50:54 EDT 2023


https://github.com/python/cpython/commit/1f74b9e933d546a015e8497e3b8728357196acc8
commit: 1f74b9e933d546a015e8497e3b8728357196acc8
branch: main
author: Victor Stinner <vstinner at python.org>
committer: vstinner <vstinner at python.org>
date: 2023-06-28T02:50:51Z
summary:

Fix c-analyzer for GCC: ignore LANG env var (#106173)

The c-analyzer doesn't support GCC localized messages, so just unset
the LANG environment variable.

files:
M Tools/c-analyzer/c_parser/preprocessor/common.py

diff --git a/Tools/c-analyzer/c_parser/preprocessor/common.py b/Tools/c-analyzer/c_parser/preprocessor/common.py
index dbe1edeef3852..06f8f4da62b22 100644
--- a/Tools/c-analyzer/c_parser/preprocessor/common.py
+++ b/Tools/c-analyzer/c_parser/preprocessor/common.py
@@ -1,6 +1,7 @@
 import contextlib
 import distutils.ccompiler
 import logging
+import os
 import shlex
 import subprocess
 import sys
@@ -40,7 +41,12 @@ def run_cmd(argv, *,
     kw.pop('kwargs')
     kwargs.update(kw)
 
-    proc = subprocess.run(argv, **kwargs)
+    # Remove LANG environment variable: the C parser doesn't support GCC
+    # localized messages
+    env = dict(os.environ)
+    env.pop('LANG', None)
+
+    proc = subprocess.run(argv, env=env, **kwargs)
     return proc.stdout
 
 



More information about the Python-checkins mailing list