New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pdb error when stepping through generator #77509
Comments
Hello: The attached python file runs a pdb interactive session for a generator. It produces an error in Python 3.7 Beta 3, but no error in 3.6. I searched for this issue and there do seem to be things that are related to it already, but I haven't investigated the cause of this issue and am not acquainted with the details of the pdb module, so I was unable to determine whether previous reports discuss this same problem. |
The interactive session result is below: GeneratorExit Exception ignored in: <async_generator object _ag at 0x0000019E069AAD90>
Traceback (most recent call last):
File "C:\Users\ricky\AppData\Local\Programs\Python\Python37\lib\types.py", line 27, in _ag
File "C:\Users\ricky\AppData\Local\Programs\Python\Python37\lib\bdb.py", line 90, in trace_dispatch
File "C:\Users\ricky\AppData\Local\Programs\Python\Python37\lib\bdb.py", line 128, in dispatch_call
File "C:\Users\ricky\AppData\Local\Programs\Python\Python37\lib\bdb.py", line 250, in break_anywhere
File "C:\Users\ricky\AppData\Local\Programs\Python\Python37\lib\bdb.py", line 49, in canonic
AttributeError: 'NoneType' object has no attribute 'abspath' |
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? |
I am on Anaconda 4.5.1 on Windows 10 (Python 3.6.5). I have confirmed that I DO get the error on another machine with the same version installed, so the lack of an error seems specific to my current machine. I do not know what could be causing this; it is very odd. |
This is a duplicate of bpo-13044.
The destructor of the asynchronous generator is called during python finalization while the trace is still active. Here is the backtrace where python is stopped just upon entering the debugger and before the exception is raised by bdb: #0 call_trace_protected (func=0x5555556c0a5b <trace_trampoline>, |
Closed as duplicate of bpo-13044. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: