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

vstinner webhook-mailer at python.org
Tue Jun 27 23:41:39 EDT 2023


https://github.com/python/cpython/commit/0373c2ccd5f60dd7b6435879e2f8c1b9ed879a3a
commit: 0373c2ccd5f60dd7b6435879e2f8c1b9ed879a3a
branch: 3.12
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: vstinner <vstinner at python.org>
date: 2023-06-28T03:41:36Z
summary:

[3.12] Fix c-analyzer for GCC: ignore LANG env var (GH-106173) (#106178)

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

The c-analyzer doesn't support GCC localized messages, so just unset
the LANG environment variable.
(cherry picked from commit 1f74b9e933d546a015e8497e3b8728357196acc8)

Co-authored-by: Victor Stinner <vstinner at python.org>

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