[issue37757] TargetScopeError not raised for comprehension scope conflict

Guido van Rossum report at bugs.python.org
Mon Aug 5 18:32:34 EDT 2019


Guido van Rossum <guido at python.org> added the comment:

[Barry]
> I know the PEP defines TargetScopeError as a subclass of SyntaxError, but it doesn't really explain why a subclass is necessary.  I think seeing "TargetScopeError" will be a head scratcher.  Why not just SyntaxError without introducing a new exception?

Hm, that's not a bad point. We report all sorts of things found by the bytecode compiler as SyntaxError.

OTOH This would require a PEP change, formal review, etc. (IMO much more so than adding the new edge case that Nick and Damien discovered.) Maybe the best way of doing this would be to implement TargetScopeError now, then start the debate about killing it, and try to get that in before beta4?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37757>
_______________________________________


More information about the Python-bugs-list mailing list