Louie Lu added the comment:

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.

----------

_______________________________________
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