Issue 12684: profile does not dump stats on exception like cProfile does (original) (raw)

Created on 2011-08-03 01:43 by anacrolix, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
exception-in-profile.patch anacrolix,2011-08-03 01:43
profiler-unhandled-exceptions.patch anacrolix,2012-03-20 14:27 review
Messages (8)
msg141591 - (view) Author: Matt Joiner (anacrolix) Date: 2011-08-03 01:43
Here's a patch that fixes it.
msg146824 - (view) Author: Matt Joiner (anacrolix) Date: 2011-11-02 04:06
Also affects 3.3.
msg155778 - (view) Author: Jim Jewett (Jim.Jewett) * (Python triager) Date: 2012-03-14 18:18
If I read that patch right, it ignores (and does not even reraise) SystemExit (unchanged), but other Exceptions currently block the dump (and your patch causes them to still dump). (1) Why is SystemExit ignored? (2) There should be tests to show that there was a dump after, say, a MyError. (3) You can use a single try ... except ... finally statement instead of two try statements.
msg155904 - (view) Author: Matt Joiner (anacrolix) Date: 2012-03-15 16:28
Jim the code was lifted verbatim from Lib/cProfile.py, line 47. That code in cProfile.py has not changed since 2006 when it was committed by Armin Rigo. I can modernize it if it's a requirement to get it committed, but I'm also okay with my conservative patch as is.
msg156188 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2012-03-17 18:22
The same fix should be applied to runctx() too. The SystemExit handling is fine, it's in the original code also. I would recommend making a single try-except-finally statement.
msg156221 - (view) Author: Matt Joiner (anacrolix) Date: 2012-03-18 01:08
I will submit a patch for this soon.
msg156415 - (view) Author: Matt Joiner (anacrolix) Date: 2012-03-20 14:43
I attached a minimal patch that additionally tidies the exception handling for {cP,p}rofile.runctx.
msg184154 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2013-03-14 09:56
I wasn't aware of this issue (sorry) and I have already fixed this back in cset 422169310b7c for the 3.4 branch. 2.7, 3.2 and 3.3 branches can still be fixed though.
History
Date User Action Args
2022-04-11 14:57:20 admin set github: 56893
2020-11-18 19:17:46 iritkatriel set status: open -> closedsuperseder: c/profile refactoringresolution: duplicatestage: patch review -> resolved
2013-03-14 09:56:21 giampaolo.rodola set messages: + versions: + Python 2.7, - Python 3.4
2013-03-13 20:50:21 ezio.melotti set nosy: + giampaolo.rodolaversions: + Python 3.4
2012-03-20 14:43:51 anacrolix set messages: +
2012-03-20 14:27:30 anacrolix set files: + profiler-unhandled-exceptions.patch
2012-03-18 01:08:05 anacrolix set messages: +
2012-03-17 18:22:29 georg.brandl set messages: +
2012-03-15 16:28:39 anacrolix set nosy: + mwh, arigomessages: +
2012-03-14 18🔞24 Jim.Jewett set nosy: + Jim.Jewettmessages: +
2012-03-14 16:46:42 eric.araujo set keywords: + needs reviewnosy: + georg.brandlstage: patch reviewversions: - Python 3.4
2012-01-23 03:42:41 anacrolix set status: languishing -> openresolution: works for me -> (no value)versions: + Python 3.4
2011-11-02 04:06:22 anacrolix set messages: + versions: + Python 3.3
2011-11-02 04:05:18 anacrolix set status: open -> languishingresolution: works for me
2011-08-03 01:43:17 anacrolix create