summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-10-07 04:30:53 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-10-07 04:30:53 (GMT)
commitdb1ed2aec36dfadc953dd9c8f7da7f00d404f9e5 (patch)
tree8111eeeb542581aea120e8587be1e3c97a2d78bc /Lib
parent6e22149cb694a1acd21d2d8ca7b614ba81cb2200 (diff)
downloadcpython-db1ed2aec36dfadc953dd9c8f7da7f00d404f9e5.zip
cpython-db1ed2aec36dfadc953dd9c8f7da7f00d404f9e5.tar.gz
cpython-db1ed2aec36dfadc953dd9c8f7da7f00d404f9e5.tar.bz2
At Guido's request, changed the code that's conceptually asserting stuff
to use assert stmts (was raising unexpected kinds of exceptions).
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/profile.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/Lib/profile.py b/Lib/profile.py
index 93e665f..1253b66 100755
--- a/Lib/profile.py
+++ b/Lib/profile.py
@@ -252,13 +252,13 @@ class Profile:
if self.cur and frame.f_back is not self.cur[-2]:
rt, rtt, rct, rfn, rframe, rcur = self.cur
if not isinstance(rframe, Profile.fake_frame):
- if rframe.f_back is not frame.f_back:
- print rframe, rframe.f_back
- print frame, frame.f_back
- raise "Bad call", self.cur[-3]
+ assert rframe.f_back is frame.f_back, ("Bad call", rfn,
+ rframe, rframe.f_back,
+ frame, frame.f_back)
self.trace_dispatch_return(rframe, 0)
- if self.cur and frame.f_back is not self.cur[-2]:
- raise "Bad call[2]", self.cur[-3]
+ assert (self.cur is None or \
+ frame.f_back is self.cur[-2]), ("Bad call",
+ self.cur[-3])
fcode = frame.f_code
fn = (fcode.co_filename, fcode.co_firstlineno, fcode.co_name)
self.cur = (t, 0, 0, fn, frame, self.cur)
@@ -272,10 +272,8 @@ class Profile:
def trace_dispatch_return(self, frame, t):
if frame is not self.cur[-2]:
- if frame is self.cur[-2].f_back:
- self.trace_dispatch_return(self.cur[-2], 0)
- else:
- raise "Bad return", self.cur[-3]
+ assert frame is self.cur[-2].f_back, ("Bad return", self.cur[-3])
+ self.trace_dispatch_return(self.cur[-2], 0)
# Prefix "r" means part of the Returning or exiting frame
# Prefix "p" means part of the Previous or older frame
@@ -311,7 +309,7 @@ class Profile:
}
- # The next few function play with self.cmd. By carefully preloading
+ # The next few functions play with self.cmd. By carefully preloading
# our parallel stack, we can force the profiled result to include
# an arbitrary string as the name of the calling function.
# We use self.cmd as that string, and the resulting stats look