Skip to content

Conversation

@vstinner
Copy link
Member

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

The c-analyzer doesn't support GCC localized messages, so just unset
the LANG environment variable.
@vstinner
Copy link
Member Author

cc @ericsnowcurrently

Example with LANG=fr_FR.UTF-8 on Fedora 38:

vstinner@mona$ make check-c-globals
python3.12 ./Tools/c-analyzer/check-c-globals.py \
	--format summary \
	--traceback
analyzing files...
.# requested file: </home/vstinner/python/main/Include/bltinmodule.h>

(...)


Traceback (most recent call last):
  (...)
  File "/home/vstinner/python/main/Tools/c-analyzer/c_parser/parser/_global.py", line 38, in parse_globals
    for srcinfo in source:
  File "/home/vstinner/python/main/Tools/c-analyzer/c_parser/parser/__init__.py", line 173, in _iter_source
    for fileinfo, line in lines:
  File "/home/vstinner/python/main/Tools/c-analyzer/c_parser/__init__.py", line 46, in <genexpr>
    srclines = ((l.file, l.data) for l in preprocessed if l.kind == 'source')
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vstinner/python/main/Tools/c-analyzer/c_parser/preprocessor/gcc.py", line 94, in _iter_lines
    raise NotImplementedError((line, expected))
NotImplementedError: ('# 0 "<interne>"', '# 0 "<built-in>"')

make: *** [Makefile:2840: check-c-globals] Error 1

@vstinner vstinner enabled auto-merge (squash) June 28, 2023 02:42
@vstinner vstinner merged commit 1f74b9e into python:main Jun 28, 2023
@miss-islington
Copy link
Contributor

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry @vstinner, I had trouble checking out the 3.12 backport branch.
Please retry by removing and re-adding the "needs backport to 3.12" label.
Alternatively, you can backport using cherry_picker on the command line.
cherry_picker 1f74b9e933d546a015e8497e3b8728357196acc8 3.12

@bedevere-bot
Copy link

GH-106177 is a backport of this pull request to the 3.11 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 28, 2023
The c-analyzer doesn't support GCC localized messages, so just unset
the LANG environment variable.
(cherry picked from commit 1f74b9e)

Co-authored-by: Victor Stinner <vstinner@python.org>
@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Jun 28, 2023
@vstinner vstinner added needs backport to 3.12 only security fixes and removed needs backport to 3.12 only security fixes labels Jun 28, 2023
@miss-islington
Copy link
Contributor

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@bedevere-bot
Copy link

GH-106178 is a backport of this pull request to the 3.12 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.12 only security fixes label Jun 28, 2023
@vstinner vstinner deleted the c_analyzer_lang branch June 28, 2023 03:17
vstinner added a commit that referenced this pull request Jun 28, 2023
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 1f74b9e)

Co-authored-by: Victor Stinner <vstinner@python.org>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 28, 2023
The c-analyzer doesn't support GCC localized messages, so just unset
the LANG environment variable.
(cherry picked from commit 1f74b9e)

Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner added a commit that referenced this pull request Jun 28, 2023
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 1f74b9e)

Co-authored-by: Victor Stinner <vstinner@python.org>
@gvanrossum
Copy link
Member

I get a similar error on macOS:

.
.
.
  File "/Users/guido/cpython/Tools/c-analyzer/c_parser/__init__.py", line 46, in <genexpr>
    srclines = ((l.file, l.data) for l in preprocessed if l.kind == 'source')
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/guido/cpython/Tools/c-analyzer/c_parser/preprocessor/gcc.py", line 94, in _iter_lines
    raise NotImplementedError((line, expected))
NotImplementedError: ('# 1 "<built-in>" 1', '# 1 "<built-in>"')
make: *** [check-c-globals] Error 1

Maybe the (extremely long) message printed upon any failure ought to include the fact that it requires GCC? Or maybe it should print something simpler, like "GCC Required" when it detects a different compiler is being used? Since I only have easy access to macOS and I occasionally need to silence this tool, it's rather annoying to have to wait for a full CI cycle to validate that my guess at fixing it works.

(CC: @ericsnowcurrently, but don't interrupt your vacation for this!)

@gvanrossum
Copy link
Member

(Also, @vstinner, thanks for the fix!)

@ericsnowcurrently
Copy link
Member

@gvanrossum, regarding the GCC requirement, if you have a minute would you mind opening an issue for this (and CC me)? I'll probably lose track of it otherwise. Thanks! (I'm in a little village in the French Alps!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants