Xavier de Gaye <xdeg...@gmail.com> added the comment:

This is a duplicate of issue 13044.

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

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>, 
    obj=<method at remote 0x7ffff6f46c98>, tstate=tstate@entry=0x555555af5eb0, 
    frame=frame@entry=Frame 0x7ffff6e63218, for file 
/home/xavier/src/python/master/Lib/types.py, line 27, in _ag (), 
what=what@entry=0, arg=None) at Python/ceval.c:4228
#1  0x00005555556757f9 in _PyEval_EvalFrameDefault (
    f=Frame 0x7ffff6e63218, for file 
/home/xavier/src/python/master/Lib/types.py, line 27, in _ag (), throwflag=1) 
at Python/ceval.c:843
#2  0x000055555567445d in PyEval_EvalFrameEx (
    f=f@entry=Frame 0x7ffff6e63218, for file 
/home/xavier/src/python/master/Lib/types.py, line 27, in _ag (), 
throwflag=throwflag@entry=1) at Python/ceval.c:536
#3  0x000055555575c0d2 in gen_send_ex (gen=gen@entry=0x7ffff6e27d48, 
arg=<optimized out>, 
    exc=exc@entry=1, closing=closing@entry=1) at Objects/genobject.c:221
#4  0x000055555575c66b in gen_close (gen=gen@entry=0x7ffff6e27d48, 
args=args@entry=0x0)
    at Objects/genobject.c:371
#5  0x000055555575c7f1 in _PyGen_Finalize (self=<async_generator at remote 
0x7ffff6e27d48>)
    at Objects/genobject.c:84
#6  0x00005555555f7c7d in PyObject_CallFinalizer (
    self=self@entry=<async_generator at remote 0x7ffff6e27d48>) at 
Objects/object.c:286
#7  0x00005555555f89c0 in PyObject_CallFinalizerFromDealloc (
    self=self@entry=<async_generator at remote 0x7ffff6e27d48>) at 
Objects/object.c:303
#8  0x000055555575ba27 in gen_dealloc (gen=gen@entry=0x7ffff6e27d48) at 
Objects/genobject.c:127
#9  0x00005555555f8a7e in _Py_Dealloc (op=<async_generator at remote 
0x7ffff6e27d48>)
    at Objects/object.c:1933
#10 0x00005555555ea25b in insertdict (mp=mp@entry=0x7ffff6e53d00, 
key=key@entry='_ag', 
    hash=-1842969574970988536, value=value@entry=None) at 
Objects/dictobject.c:1067
#11 0x00005555555eb8a0 in PyDict_SetItem (
    op=op@entry=Python Exception <class 'gdb.error'> Attempt to extract a 
component of a value that is not a struct/class/union.: 
, key='_ag', value=None) at Objects/dictobject.c:1454
#12 0x00005555555f764f in _PyModule_ClearDict (
    d=Python Exception <class 'gdb.error'> Attempt to extract a component of a 
value that is not a struct/class/union.: 
) at Objects/moduleobject.c:606
#13 0x00005555555f793f in _PyModule_Clear (m=m@entry=<module at remote 
0x7ffff6e57758>)
    at Objects/moduleobject.c:577
#14 0x000055555569debe in PyImport_Cleanup () at Python/import.c:544
#15 0x00005555556ac463 in Py_FinalizeEx () at Python/pylifecycle.c:1094
#16 0x00005555555b2136 in pymain_main (pymain=pymain@entry=0x7fffffffe420) at 
Modules/main.c:2664
#17 0x00005555555b22c3 in _Py_UnixMain (argc=<optimized out>, argv=<optimized 
out>)
    at Modules/main.c:2697
#18 0x00005555555ad403 in main (argc=<optimized out>, argv=<optimized out>)
    at ./Programs/python.c:15

----------
nosy: +xdegaye

_______________________________________
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