[issue9285] Add a profile decorator to profile and cProfile

2017-04-22 Thread Louie Lu

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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9285] Add a profile decorator to profile and cProfile

2017-04-22 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

Original patch still applies. Not sure if we should continue with that one or 
with your new PR. The original assertion error is still there. I CCed Tim 
Peters as it appears he's the one who originally added it in 2001 - maybe he 
has some clue.

--
versions: +Python 3.7 -Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9285] Add a profile decorator to profile and cProfile

2017-04-20 Thread Louie Lu

Changes by Louie Lu :


--
pull_requests: +1335

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9285] Add a profile decorator to profile and cProfile

2017-02-25 Thread Fred L. Drake, Jr.

Changes by Fred L. Drake, Jr. :


--
nosy:  -fdrake

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9285] Add a profile decorator to profile and cProfile

2017-02-24 Thread Louie Lu

Changes by Louie Lu :


--
pull_requests: +257

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9285] Add a profile decorator to profile and cProfile

2017-02-24 Thread Louie Lu

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 
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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9285] Add a profile decorator to profile and cProfile

2017-02-24 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

The original patch is basically blocked by the cryptic assertion error reported 
above. It's not clear what it means or how to work around it.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9285] Add a profile decorator to profile and cProfile

2017-02-24 Thread Guido van Rossum

Changes by Guido van Rossum :


--
nosy:  -gvanrossum

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9285] Add a profile decorator to profile and cProfile

2017-02-24 Thread Louie Lu

Louie Lu added the comment:

Ping. Is there any reason why this patch doesn't accept?

--
nosy: +louielu

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9285] Add a profile decorator to profile and cProfile

2013-02-25 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
nosy: +bjorns

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9285
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9285] Add a profile decorator to profile and cProfile

2013-02-25 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
versions: +Python 3.4 -Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9285
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9285] Add a profile decorator to profile and cProfile

2013-02-25 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

Ok, here's an updated patch modeled after:
http://hg.python.org/cpython/rev/422169310b7c

It works fine with cProfile.py but not with profile.py where I get this 
exception when I try to use the context manager (tests can be run in order to 
reproduce it):

  File /home/giampaolo/svn/python/3.4-profile/Lib/profile.py, line 339, in 
trace_dispatch_return
assert frame is self.cur[-2].f_back, (Bad return, self.cur[-3])
AssertionError: ('Bad return', ('profile', 0, ''))

I have no clue what this error means.
I wasn't able to add a context manager for profile.Profile for the same reason.
Any clue?

--
nosy: +arigo
Added file: http://bugs.python.org/file29242/profile3.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9285
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9285] Add a profile decorator to profile and cProfile

2013-02-25 Thread Lukas Lueg

Changes by Lukas Lueg lukas.l...@gmail.com:


--
nosy:  -ebfe

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9285
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9285] Add a profile decorator to profile and cProfile

2013-02-12 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' g.rod...@gmail.com:


--
nosy: +georg.brandl

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9285
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9285] Add a profile decorator to profile and cProfile

2013-02-12 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

A preliminary patch for cProfile.py is in attachment. Will make changes to 
profile.py later.

--
Added file: http://bugs.python.org/file29050/profile.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9285
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9285] Add a profile decorator to profile and cProfile

2013-02-11 Thread Guido van Rossum

Guido van Rossum added the comment:

Brief comments:

- Please don't call it profile -- we already have a module by that name.

- Please make it so that both the decorator and context manager can specify a 
file where to dump the raw data -- basically it needs to have the same 
functionality as the functions run()/runctx()/runcall() (the latter TBD, see 
issue 17130).

- Please also make Profile object itself the context manager -- all you have to 
do is add __enter__() and __exit__() that call enable() and disable().  (But 
this doesn't completely replace the global function, which has more 
functionality -- it prints the profile or dumps the data).

--
nosy: +gvanrossum

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9285
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9285] Add a profile decorator to profile and cProfile

2013-02-11 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

Ok, will look into this soon.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9285
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9285] Add a profile decorator to profile and cProfile

2012-01-25 Thread Yuval Greenfield

Changes by Yuval Greenfield ubershme...@gmail.com:


--
nosy: +ubershmekel

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9285
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9285] Add a profile decorator to profile and cProfile

2011-07-13 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

See #8916 for adding standard functionality similar to the decorator module.

--
components: +Extension Modules -Benchmarks
dependencies: +Move PEP 362 (function signature objects) into inspect
nosy: +eric.araujo
title: A decorator for cProfile and profile modules - Add a profile decorator 
to profile and cProfile

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9285
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9285] Add a profile decorator to profile and cProfile

2011-07-13 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +ezio.melotti

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9285
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9285] Add a profile decorator to profile and cProfile

2011-07-13 Thread Collin Winter

Changes by Collin Winter coll...@gmail.com:


--
nosy:  -collinwinter

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9285
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com