This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Setting PYTHONASYNCIODEBUG breaks warnings
Type: behavior Stage:
Components: asyncio Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, def_bk, ods, yselivanov
Priority: normal Keywords:

Created on 2019-03-07 06:58 by ods, last changed 2022-04-11 14:59 by admin.

Messages (3)
msg337366 - (view) Author: Denis S. Otkidach (ods) * Date: 2019-03-07 06:58
Test script:

-->8--
import asyncio

@asyncio.coroutine
def test():
    with (yield from asyncio.Lock()):
        pass

asyncio.run(test())
-->8--

Correct behavior without flag (warning is reported and points to correct line of code):
---
$ python test.py 
test.py:5: DeprecationWarning: 'with (yield from lock)' is deprecated use 'async with lock' instead
  with (yield from asyncio.Lock()):
---

Setting PYTHONASYNCIODEBUG flag disables warning:
---
$ PYTHONASYNCIODEBUG=1 python test.py
$
---

Warning is back explicitly turned on, but points to incorrect position in stack:
---
$ PYTHONASYNCIODEBUG=1 python -Wall test.py 
lib/python3.8/asyncio/coroutines.py:58: DeprecationWarning: 'with (yield from lock)' is deprecated use 'async with lock' instead
  return self.gen.send(None)
---

Another way to enable debugging doesn't disable warnings, but break its location too:
---
$ python -Xdev test.py 
lib/python3.8/asyncio/coroutines.py:58: DeprecationWarning: 'with (yield from lock)' is deprecated use 'async with lock' instead
  return self.gen.send(None)
---
msg345122 - (view) Author: Alexey Kostyrin (def_bk) Date: 2019-06-10 10:49
Can not reproduce - warning is displayed with PYTHONASYNCIODEBUG=1 
Python version:
Python 3.8.0b1+ (heads/3.8:3f7629d93c, Jun 10 2019, 13:46:55) 
[Clang 10.0.0 (clang-1000.10.44.4)] on darwin
msg357499 - (view) Author: Denis S. Otkidach (ods) * Date: 2019-11-26 14:37
It's fixed in 3.8 final, but the problem persists in 3.7.5
History
Date User Action Args
2022-04-11 14:59:12adminsetgithub: 80402
2019-11-26 14:37:50odssetmessages: + msg357499
versions: - Python 3.8
2019-06-10 10:49:15def_bksetnosy: + def_bk
messages: + msg345122
2019-03-07 06:58:38odscreate