Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

Thank you for your report Rick. But I get the same error in 3.6.

An AttributeError is raised if the debugger runs at the interpreter shutdown 
stage (sys.is_finalizing() returns True). sys.path was set to None at the 
beginning of modules cleanup. The debugger traces the _ag() asynchronous 
generator in types.py. You can see some details when run Python with option -v.

$ ./python -v ../demo.py
...
import 'pdb' # <_frozen_importlib_external.SourceFileLoader object at 
0x7f5b45debae8>
# extension module 'readline' loaded from 
'/home/serhiy/py/cpython/build/lib.linux-x86_64-3.8-pydebug/readline.cpython-38dm-x86_64-linux-gnu.so'
# extension module 'readline' executed from 
'/home/serhiy/py/cpython/build/lib.linux-x86_64-3.8-pydebug/readline.cpython-38dm-x86_64-linux-gnu.so'
import 'readline' # <_frozen_importlib_external.ExtensionFileLoader object at 
0x7f5b45d94608>
GeneratorExit

# clear builtins._
# clear sys.path
# clear sys.argv
...
# cleanup[3] wiping re
# destroy _locale
# destroy sre_compile
# destroy copyreg
# cleanup[3] wiping enum
# cleanup[3] wiping types
Exception ignored in: <async_generator object _ag at 0x7f6de03f0eb8>
Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/types.py", line 27, in _ag
  File "/home/serhiy/py/cpython/Lib/bdb.py", line 90, in trace_dispatch
  File "/home/serhiy/py/cpython/Lib/bdb.py", line 128, in dispatch_call
  File "/home/serhiy/py/cpython/Lib/bdb.py", line 250, in break_anywhere
  File "/home/serhiy/py/cpython/Lib/bdb.py", line 49, in canonic
AttributeError: 'NoneType' object has no attribute 'abspath'

Adding "del _ag" in types.py fixes this issue. But there are open questions.

Is it good that the debugger is enabled at the shutdown stage?

Why the code of the never used asynchronous generator is executed at all?

----------
nosy: +pitrou, serhiy.storchaka, yselivanov
versions: +Python 3.6, Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33328>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to