[issue37299] RuntimeWarning is NOT raised
Paul Ganssle
report at bugs.python.org
Mon Jun 17 03:31:25 EDT 2019
Paul Ganssle <p.ganssle at gmail.com> added the comment:
I think the reason for the difference here is in the `no_error` function you never actually create the coroutine `true()`, so there's nothing to warn about.
One thing that's confusing things about this example is that the `false()` evaluates to True, because it returns a coroutine object (rather than the value `False`):
>>> async def false():
...: return False
...:
>>> bool(false())
True
If you expand your `false() or true()` statement, it's equivalent to:
x = false()
if not x:
x = true()
return await x
Since `false()` is truthy, you don't expect true() to ever be called, hence no warning.
@YoSTEALTH Does this make sense? Does it solve the issue?
----------
nosy: +p-ganssle
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37299>
_______________________________________
More information about the Python-bugs-list
mailing list