> Right again. The simplest rule to remember seems to be "don't use yield or
> yield-from inside a with-statement". You can relax it by limiting it to
> context managers that manage any kind of shared resource, but that is
> probably already too subtle: e.g. yielding inside "with open(file) as f"
> seems fine, but yielding inside "with lock" is problematic, since the other
> side might try to acquire the same lock, and deadlock.
>

This seems like the kind of thing that might warrant a pylint warning.
Probably the more general case, requiring people to think about it and
suppress the warning with an explanatory comment (or write the code in a
different manner) when they are doing something known to be safe.

-gps
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to