Louie Lu added the comment:

giampaolo: it seems that contextmanager will somehow make a bad return in  
`trace_dispatch_return`:

$ ./python tests.py
# logging.fatal('%r %r' % (frame.f_code.co_name, self.cur[-3]))
CRITICAL:root:'runblock' '' ('profile', 0, '')
CRITICAL:root:'__enter__' '' ('profile', 0, '')
Traceback (most recent call last):
  File "tests.py", line 18, in <module>
    with p.runblock():
  File "/home/grd/Python/cpython/Lib/contextlib.py", line 82, in __enter__
    return next(self.gen)
  File "/home/grd/Python/cpython/Lib/profile.py", line 256, in trace_dispatch_i
    if self.dispatch[event](self, frame, t):
  File "/home/grd/Python/cpython/Lib/profile.py", line 346, in 
trace_dispatch_return
    raise AssertionError("Bad return", self.cur[-3])
AssertionError: ('Bad return', ('profile', 0, ''))

I make a workaround in GitHub PR, that skip the assert when self.cur[-3] is 
('profile', 0, ''), and this work fine with your test cases.

p.s. I'm not very sure about the assertion of bad return, maybe this workaround 
may cause some side affact I didn't notice.

----------

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

Reply via email to