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

Python3.12 test error: SyntaxError: unmatched ')' #275

Closed
arkamar opened this issue May 27, 2023 · 1 comment
Closed

Python3.12 test error: SyntaxError: unmatched ')' #275

arkamar opened this issue May 27, 2023 · 1 comment

Comments

@arkamar
Copy link

arkamar commented May 27, 2023

Test suit fails with Python3.12 with following error message:

======================================================= ERRORS ========================================================
__________________________________ ERROR collecting tests/hypothesis_vector_test.py ___________________________________
/usr/lib/python3.12/site-packages/_pytest/python.py:617: in _importtestmodule
    mod = import_path(self.path, mode=importmode, root=self.config.rootpath)
/usr/lib/python3.12/site-packages/_pytest/pathlib.py:564: in import_path
    importlib.import_module(module_name)
/usr/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1293: in _gcd_import
    ???
<frozen importlib._bootstrap>:1266: in _find_and_load
    ???
<frozen importlib._bootstrap>:1237: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:841: in _load_unlocked
    ???
/usr/lib/python3.12/site-packages/_pytest/assertion/rewrite.py:178: in exec_module
    exec(co, module.__dict__)
tests/hypothesis_vector_test.py:48: in <module>
    PVectorAndLists = st.lists(st.builds(RefCountTracker)).map(
/usr/lib/python3.12/site-packages/hypothesis/strategies/_internal/strategies.py:347: in map
    if is_identity_function(pack):
/usr/lib/python3.12/site-packages/hypothesis/internal/reflection.py:638: in is_identity_function
    return bool(re.fullmatch(r"lambda (\w+): \1", get_pretty_function_description(f)))
/usr/lib/python3.12/site-packages/hypothesis/internal/reflection.py:432: in get_pretty_function_description
    return extract_lambda_source(f)
/usr/lib/python3.12/site-packages/hypothesis/internal/reflection.py:312: in extract_lambda_source
    source = inspect.getsource(f)
/usr/lib/python3.12/inspect.py:1274: in getsource
    lines, lnum = getsourcelines(object)
/usr/lib/python3.12/inspect.py:1266: in getsourcelines
    return getblock(lines[lnum:]), lnum + 1
/usr/lib/python3.12/inspect.py:1241: in getblock
    for _token in tokens:
/usr/lib/python3.12/tokenize.py:451: in _tokenize
    for token in _generate_tokens_from_c_tokenizer(source, extra_tokens=True):
/usr/lib/python3.12/tokenize.py:542: in _generate_tokens_from_c_tokenizer
    for info in c_tokenizer.TokenizerIter(source, extra_tokens=extra_tokens):
E     File "<string>", line 1
E       lambda l: (l, pvector(l)))
E                                ^
E   SyntaxError: unmatched ')'
================================================== warnings summary ===================================================
../../../../../../../usr/lib/python3.12/site-packages/_pytest/assertion/rewrite.py:691
  /usr/lib/python3.12/site-packages/_pytest/assertion/rewrite.py:691: DeprecationWarning: Attribute s is deprecated and will be removed in Python 3.14; use value instead
    doc = item.value.s

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=============================================== short test summary info ===============================================
ERROR tests/hypothesis_vector_test.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================= 1 warning, 1 error in 2.68s =============================================

However, all tests pass when I apply this change:

--- a/tests/hypothesis_vector_test.py
+++ b/tests/hypothesis_vector_test.py
@@ -45,8 +45,7 @@ def test_setup(gc_when_done):


 # Pairs of a list and corresponding pvector:
-PVectorAndLists = st.lists(st.builds(RefCountTracker)).map(
-    lambda l: (l, pvector(l)))
+PVectorAndLists = st.lists(st.builds(RefCountTracker)).map(lambda l: (l, pvector(l)) )


 def verify_inputs_unmodified(original):
@mgorny
Copy link

mgorny commented May 28, 2023

This turned out to be actually a bug in CPython.

@arkamar arkamar closed this as completed May 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants