bpo-41696: Fix handling of debug mode in asyncio.run (#22069)

* bpo-41696: Fix handling of debug mode in asyncio.run

This allows PYTHONASYNCIODEBUG or -X dev to enable asyncio debug mode
when using asyncio.run

* 📜🤖 Added by blurb_it.

Co-authored-by: hauntsaninja <>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
diff --git a/Lib/asyncio/runners.py b/Lib/asyncio/runners.py
index 03ce333..268635d 100644
--- a/Lib/asyncio/runners.py
+++ b/Lib/asyncio/runners.py
@@ -5,7 +5,7 @@
 from . import tasks
 
 
-def run(main, *, debug=False):
+def run(main, *, debug=None):
     """Execute the coroutine and return the result.
 
     This function runs the passed coroutine, taking care of
@@ -39,7 +39,8 @@
     loop = events.new_event_loop()
     try:
         events.set_event_loop(loop)
-        loop.set_debug(debug)
+        if debug is not None:
+            loop.set_debug(debug)
         return loop.run_until_complete(main)
     finally:
         try: