Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ccpp-framework not working with Python 3.11 #457

Closed
climbfuji opened this issue Nov 23, 2022 · 0 comments · Fixed by #456
Closed

ccpp-framework not working with Python 3.11 #457

climbfuji opened this issue Nov 23, 2022 · 0 comments · Fixed by #456
Assignees
Labels

Comments

@climbfuji
Copy link
Collaborator

Description

@DusanJovic-NOAA reported the following error with the newly relerased Python 3.11 on Fedora 37 (cont'd below):

Traceback (most recent call last):
  File "/home/dusan/test/simple-ufs/src/model/FV3/ccpp/framework/scripts/ccpp_prebuild.py", line 21, in <module>
    from metadata_parser import merge_dictionaries, parse_scheme_tables, parse_variable_tables
  File "/home/dusan/test/simple-ufs/src/model/FV3/ccpp/framework/scripts/metadata_parser.py", line 19, in <module>
    from metadata_table import MetadataTable, parse_metadata_file
  File "/home/dusan/test/simple-ufs/src/model/FV3/ccpp/framework/scripts/metadata_table.py", line 132, in <module>
    from ccpp_state_machine  import CCPP_STATE_MACH
  File "/home/dusan/test/simple-ufs/src/model/FV3/ccpp/framework/scripts/ccpp_state_machine.py", line 15, in <module>
    CCPP_STATE_MACH = StateMachine((('initialize', 'uninitialized',
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dusan/test/simple-ufs/src/model/FV3/ccpp/framework/scripts/state_machine.py", line 81, in __init__
    self.add_transition(trans[0], trans[1], trans[2], trans[3])
  File "/home/dusan/test/simple-ufs/src/model/FV3/ccpp/framework/scripts/state_machine.py", line 88, in add_transition
    self[name] = (init_state, final_state, regex)
    ~~~~^^^^^^
  File "/home/dusan/test/simple-ufs/src/model/FV3/ccpp/framework/scripts/state_machine.py", line 165, in __setitem__
    regex = re.compile(value[2] + r"$")
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/re/__init__.py", line 227, in compile
    return _compile(pattern, flags)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/re/__init__.py", line 294, in _compile
    p = _compiler.compile(pattern, flags)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/re/_compiler.py", line 743, in compile
    p = _parser.parse(p, flags)
        ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/re/_parser.py", line 980, in parse
    p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/re/_parser.py", line 455, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/re/_parser.py", line 863, in _parse
    p = _parse_sub(source, state, sub_verbose, nested + 1)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/re/_parser.py", line 455, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/re/_parser.py", line 841, in _parse
    raise source.error('global flags not at the start '
re.error: global flags not at the start of the expression at position 3

This is because global inline flags are no longer allowed in the middle of regular expressions, only at the beginning (see fail2ban/fail2ban#3260 for example).

Steps to Reproduce

Find yourself a machine with Python 3.11 (ideally Fedora 37, where it is native) and run one set of unit tests:

cd tests
PYTHONPATH=$PWD/../scripts/parse_tools:$PWD/../scripts:$PYTHONPATH python3.11 test_metadata_parser.py

Additional Context

Another problem is that with Python 3.11 installed on a system that doesn't have Python 3.11 as default, pytest doesn't work (see pytest-dev/py#273). Thus, even after fixing the issue reported above in PR #456, I cannot run all unit tests with Python 3.11.

Output

See above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant