Barry Warsaw wrote:
> The PEP doesn’t really go into the rationale for why a new exception is being 
> defined,
> and in the issue I’ve argued that we should just raise SyntaxError in those 
> cases.  To me,
> “TargetScopeError” is pretty obscure and doesn’t give users an obvious clue 
> as to what’s
> going wrong, without searching the interwebs.

Barry Warsaw wrote:
> Serhiy points out that we have IndentationError and TabError subclasses of 
> SyntaxError,
> but those feel different to me because the exception names themselves are 
> clear and
> descriptive, and lead to obvious actionable remedies.

I find myself in agreement that SyntaxError should be raised for the above 
reasons, as
long as the error message can adequately explain to the user that it's an issue 
with the
scope they're referring to:

``SyntaxError: Invalid scope defined by walrus operator: 'i := 10 for i in 
range(5)'``

To make it a bit more more succinct, "by walrus operator" could be potentially 
removed. 

I don't think there's anything inherently wrong with the users looking up the 
name of the
exception for more information, but it should not be required to gain a basic
understanding of what the error is referring to.

Also, I'm not entirely convinced that this would be a frequent enough 
occurrence to justify
creating a subclass of SyntaxError instead of simply using a custom message to
describe the issue.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/ZE3JNHAW46QCOAYQRNKYUABFK5YEJCZH/

Reply via email to