-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
SyntaxError: unmatched ')' with whitespace in lambda? #105042
Comments
I'm trying to reduce it more to be standalone (not dependent on hypothesis) but not sure if I'll get there. |
This is also happening on pydantic-core, see https://github.com/pydantic/pydantic-core/actions/runs/5105586096/jobs/9177258340?pr=629 |
Bug: python/cpython#105042 Signed-off-by: Sam James <sam@gentoo.org>
Will try to fix this this next week |
Meanwhile can someone provide a self contained reproducer that doesn't rely on hypothesis? |
@lysnikolaou if you have some spare cycles can you look at this? The problem is that the tokeniser now raises with unbalanced parens when before it didn't and this now doesn't allow to analyse code that is not syntactically correct by its own. We may need to emit ERRORTOKEN tokens for these or something like that. |
This all comes from import inspect
(
); x = lambda: 1
inspect.getsource(x) As @pablogsal said, it's because |
Yeah but we need to ensure we don't leave the tokenizer in a bad state by ignoring the errors |
…nize (pythonGH-105061) (cherry picked from commit 70f315c) Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
I'm resolving this, please feel free to reopen if something is missing after the fix |
Bug report
Testing on tip of 3.12 which includes the fix for #105013 (thanks!), I get the following difference in behaviour with Python 3.11 vs tip of Python 3.12:
With Python 3.12, I get:
But with Python 3.11, I get:
If I change the program to drop the whitespace, it works in 3.12 too:
I noticed this w/ a test failure in priority (the output is huge, so just a snippet here)
and a perhaps more useful test failure in hypothesis, which priority uses:
See also #105013.
Your environment
Linked PRs
The text was updated successfully, but these errors were encountered: