classification
Title: test_check_c_globals "crashed" and then "FutureWarning: Possible nested set at position 12"
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.11, Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: eric.snow, iritkatriel, miss-islington, serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2021-07-30 18:27 by iritkatriel, last changed 2021-09-15 16:44 by serhiy.storchaka. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 28351 merged serhiy.storchaka, 2021-09-15 11:13
PR 28353 merged miss-islington, 2021-09-15 14:08
Messages (5)
msg398600 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-07-30 18:27
% ./python.exe -E -We -m test -v test_check_c_globals

...

test test_check_c_globals crashed -- Traceback (most recent call last):
  File "/Users/iritkatriel/src/cpython-1/Lib/test/libregrtest/runtest.py", line 335, in _runtest_inner
    refleak = _runtest_inner2(ns, test_name)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/iritkatriel/src/cpython-1/Lib/test/libregrtest/runtest.py", line 280, in _runtest_inner2
    the_module = importlib.import_module(abstest)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/iritkatriel/src/cpython-1/Lib/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1061, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1038, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1015, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 689, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 894, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/iritkatriel/src/cpython-1/Lib/test/test_check_c_globals.py", line 6, in <module>
    from cpython.__main__ import main
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/iritkatriel/src/cpython-1/Tools/c-analyzer/cpython/__main__.py", line 18, in <module>
    from c_parser.info import KIND
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/iritkatriel/src/cpython-1/Tools/c-analyzer/c_parser/__init__.py", line 1, in <module>
    from .parser import parse as _parse
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/iritkatriel/src/cpython-1/Tools/c-analyzer/c_parser/parser/__init__.py", line 119, in <module>
    from ..info import ParsedItem
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/iritkatriel/src/cpython-1/Tools/c-analyzer/c_parser/info.py", line 10, in <module>
    import c_common.tables as _tables
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/iritkatriel/src/cpython-1/Tools/c-analyzer/c_common/tables.py", line 236, in <module>
    _COLSPEC_RE = re.compile(textwrap.dedent(r'''
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/iritkatriel/src/cpython-1/Lib/re.py", line 229, in compile
    return _compile(pattern, flags)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/iritkatriel/src/cpython-1/Lib/re.py", line 281, in _compile
    p = sre_compile.compile(pattern, flags)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/iritkatriel/src/cpython-1/Lib/sre_compile.py", line 764, in compile
    p = sre_parse.parse(p, flags)
        ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/iritkatriel/src/cpython-1/Lib/sre_parse.py", line 948, in parse
    p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/iritkatriel/src/cpython-1/Lib/sre_parse.py", line 443, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/iritkatriel/src/cpython-1/Lib/sre_parse.py", line 834, in _parse
    p = _parse_sub(source, state, sub_verbose, nested + 1)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/iritkatriel/src/cpython-1/Lib/sre_parse.py", line 443, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/iritkatriel/src/cpython-1/Lib/sre_parse.py", line 540, in _parse
    warnings.warn(
    ^^^^^^^^^^^^^^
FutureWarning: Possible nested set at position 12

test_check_c_globals failed (uncaught exception)
msg401827 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-09-15 13:09
The warning comes from this regex: Tools/c-analyzer/c_common/tables.py", line 236

_COLSPEC_RE = re.compile(textwrap.dedent(r'''
    ^
    (?:
        [[]
        (
            (?: [^\s\]] [^\]]* )?
            [^\s\]]
        )  # <label>
        []]
    )?
    ( \w+ )  # <field>
    (?:
        (?:
            :
            ( [<^>] )  # <align>
            ( \d+ )  # <width1>
        )
        |
        (?:
            (?:
                :
                ( \d+ )  # <width2>
            )?
            (?:
                :
                ( .*? )  # <fmt>
            )?
        )
    )?
    $
'''), re.VERBOSE)
msg401841 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-09-15 14:08
Yes, [[] looks as the start of a character set containing nested sets (e.g. "[[a-z]--[p-q]]"). This feature is supported by regex and can be added in future versions of re, breaking the code which contain such combinations.
msg401842 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-09-15 14:08
New changeset 1a9ef5798525bbb39a16c8af5c435b97352ee027 by Serhiy Storchaka in branch 'main':
bpo-44786: Fix a warning in RE in c-analyzer (GH-28351)
https://github.com/python/cpython/commit/1a9ef5798525bbb39a16c8af5c435b97352ee027
msg401853 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-09-15 16:43
New changeset 89966f59c2e1d0558f8126458acc7d7ae2a8fef5 by Miss Islington (bot) in branch '3.10':
bpo-44786: Fix a warning in RE in c-analyzer (GH-28351) (GH-28353)
https://github.com/python/cpython/commit/89966f59c2e1d0558f8126458acc7d7ae2a8fef5
History
Date User Action Args
2021-09-15 16:44:21serhiy.storchakasetstatus: open -> closed
type: behavior
stage: patch review -> resolved
resolution: fixed
versions: + Python 3.10
2021-09-15 16:43:29serhiy.storchakasetmessages: + msg401853
2021-09-15 14:08:56miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request26767
2021-09-15 14:08:55serhiy.storchakasetmessages: + msg401842
2021-09-15 14:08:19serhiy.storchakasetmessages: + msg401841
2021-09-15 13:09:36vstinnersetnosy: + eric.snow, vstinner
messages: + msg401827
2021-09-15 11:13:27serhiy.storchakasetkeywords: + patch
nosy: + serhiy.storchaka

pull_requests: + pull_request26765
stage: patch review
2021-07-30 18:28:18iritkatrielsetcomponents: + Tests
2021-07-30 18:27:57iritkatrielcreate