[Zope-Checkins] CVS: Zope2 - Test.py:1.35.124.1
fred@digicool.com
fred@digicool.com
Tue, 5 Jun 2001 16:25:39 -0400 (EDT)
Update of /cvs-repository/Zope2/lib/python/ZPublisher
In directory korak.digicool.com:/tmp/cvs-serv9158/lib/python/ZPublisher
Modified Files:
Tag: zope-2_3-branch
Test.py
Log Message:
Do not test for sys.exc_info(); it was already present in Python 2.1.
This simplifies code and improves performance (very slightly).
In two places, object type was tested by calling type() on each of two
values and comparing the results (4 dict lookups, 2 Python->C function
calls). Replace each with an isinstance() call comparing to a saved
type object (3 dict lookups, 1 Python->C function call, more future-proof).
--- Updated File Test.py in package Zope2 --
--- Test.py 1999/09/03 21:43:53 1.35
+++ Test.py 2001/06/05 20:25:39 1.35.124.1
@@ -169,7 +169,9 @@
import sys, traceback, profile, os, getopt, string
from time import clock
repeat_count=100
+TupleType=type(())
+
def main():
import sys, os, getopt, string
global repeat_count
@@ -260,13 +262,11 @@
for k, v in extra.items(): request[k]=v
response = publish(request, module_name, after_list, debug=debug)
except SystemExit, v:
- if hasattr(sys, 'exc_info'): must_die=sys.exc_info()
- else: must_die = SystemExit, v, sys.exc_info()[2]
+ must_die=sys.exc_info()
response.exception(must_die)
except ImportError, v:
- if type(v) is type(()) and len(v)==3: must_die=v
- elif hasattr(sys, 'exc_info'): must_die=sys.exc_info()
- else: must_die = SystemExit, v, sys.exc_info()[2]
+ if isinstance(v, TupleType) and len(v)==3: must_die=v
+ else: must_die=sys.exc_info()
response.exception(1, v)
except:
response.exception()
@@ -411,7 +411,7 @@
if b: exec b in dbdata
for b in dbdata['breakpoints']:
- if type(b) is type(()):
+ if isinstance(b, TupleType):
apply(db.set_break,b)
else:
fbreak(db,b)