You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ast.parse creates only Constant(value=0) nodes for a case +0: pattern, which is inconsistent. #152708
+0 is parsed to Constant(value=0) instead of UnaryOp(op=UAdd(),operand=Constant(value=0)) when it is used as a match-expression.
This was really unexpected for me and can maybe produce some problems with ast.parse/unparse roundtripps or code which works with the ast and require workarounds (like in my case)
Is it possible to implement this in a way that it generates UnaryOp(...)?
Activity
Twix1288 commentedon Jun 30, 2026
I would love to look at this bug to fix
Add NEWS entry for pythongh-152708
gh-152708: Fix AST generation asymmetry for unary positive in match s…
[3.15] gh-152708: Fix AST generation asymmetry for unary positive in …
test: python/cpython#152708 is merged and part of 0.15.0.rc3
test: python/cpython#152708 is merged and part of 0.15.0.rc3
3.15 support (#109)