This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author louielu
Recipients arigo, benjamin.peterson, bjorns, debatem1, eric.araujo, ezio.melotti, fdrake, georg.brandl, giampaolo.rodola, louielu, nbastin, pitrou, rhettinger, tim.peters, tleeuwenburg@gmail.com, ubershmekel
Date 2017-02-25.07:35:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1488008122.98.0.820957128131.issue9285@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2017-02-25 07:35:23louielusetrecipients: + louielu, tim.peters, fdrake, arigo, georg.brandl, rhettinger, nbastin, pitrou, giampaolo.rodola, benjamin.peterson, ezio.melotti, eric.araujo, tleeuwenburg@gmail.com, debatem1, ubershmekel, bjorns
2017-02-25 07:35:22louielusetmessageid: <1488008122.98.0.820957128131.issue9285@psf.upfronthosting.co.za>
2017-02-25 07:35:22louielulinkissue9285 messages
2017-02-25 07:35:22louielucreate