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, georg.brandl, giampaolo.rodola, louielu, nbastin, pitrou, rhettinger, tim.peters, tleeuwenburg@gmail.com, ubershmekel
Date 2017-04-23.04:44:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1492922647.71.0.902472039494.issue9285@psf.upfronthosting.co.za>
In-reply-to
Content
Giampaolo, the assertion is still worked good, and no need to remove them. The assertion is to prevent dispatch return too more, to return upper then when the profiler was created.

The problem why profile __enter__ can't work, is because it misses the simulate_call between __enter__ and upper frame.

The original scenes:

pr = profile.Profile()  # It will call simulate_call at the end of init
sys.setprofile(pr.dispatcher)
# profile
sys.setprofile(None)

The break scenes:

def profile_helper(pr):
    sys.setprofile(pr.dispatcher)
    # Function will return None, dead here

pr = profile.Profile()  # Create simulate_call
# We go into profile_helper, but didn't simulate a call!! (didn't setprofile yet)
profile_helper(pr)      
sys.setprofile(None)

The #30113 issue fix this:

def profile_helper(pr):
    pr._adjust_frame()  # call simuate_call here
    sys.setprofile(pr.dispatcher)

pr = profile.Profile()  # Create simulate_call
profile_helper(pr)      
sys.setprofile(None)

Creating this simuate_call, then profiler can go back to the upper frame without error.
History
Date User Action Args
2017-04-23 04:44:07louielusetrecipients: + louielu, tim.peters, arigo, georg.brandl, rhettinger, nbastin, pitrou, giampaolo.rodola, benjamin.peterson, ezio.melotti, eric.araujo, tleeuwenburg@gmail.com, debatem1, ubershmekel, bjorns
2017-04-23 04:44:07louielusetmessageid: <1492922647.71.0.902472039494.issue9285@psf.upfronthosting.co.za>
2017-04-23 04:44:07louielulinkissue9285 messages
2017-04-23 04:44:07louielucreate