On Sat, Apr 14, 2018 at 7:33 AM, Kirill Balunov <kirillbalu...@gmail.com> wrote:
>
>
> 2018-04-13 23:31 GMT+03:00 Chris Angelico <ros...@gmail.com>:
>>
>>
>> >     # but these are subtly different and will be a trap for the unwary
>> >     with expression as name:  # name is set to __enter__()
>> >     with (expression as name):  # name is not set to __enter__()
>>
>> And that's a good reason to reject the last one with a SyntaxError,
>> but that creates an odd discrepancy where something that makes perfect
>> logical sense is rejected.
>>
>
> Maybe it does not suit you, but what do you think about `SyntaxWarning`
> instead of `SyntaxError` for both `with` and `except`. By analogy how it was
> done for `global name` into function body prior to Python 3.6?

Warnings are often not seen. For an error this subtle, a warning
wouldn't be enough.

Good call though; that was one of the considerations, and if we knew
for sure that warnings could be seen by the right people, they could
be more useful for these cases.

ChrisA
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to