Coming from other languages, it’s easy to accidentally write && or || in place of and or or. I've even seen experienced people reach for them when doing boolean operations on Numpy arrays and the like.
It could be helpful to add a specialized syntax error. Something like:
@Aniketsy I would prefer that a parser expert takes care of that. This is likely a non-trivial change so to make it easier to review, it would be better if a core dev or someone familiar with the parser takes care of this.
Activity
Aniketsy commented on Mar 27, 2026
@brianschubert yes, i think we should improve error message, with your permission i can create PR for this , Thanks!
picnixz commented on Mar 27, 2026
@Aniketsy I would prefer that a parser expert takes care of that. This is likely a non-trivial change so to make it easier to review, it would be better if a core dev or someone familiar with the parser takes care of this.
skirpichev commented on Mar 28, 2026
How about following patch:
?
gh-146495: Improve `SyntaxError` message for `&&` and `||` operators (#…