]> granicus.if.org Git - python/commitdiff
Fix pybench so it works -- Larry Hastings.
authorGuido van Rossum <guido@python.org>
Sat, 13 Jan 2007 23:54:39 +0000 (23:54 +0000)
committerGuido van Rossum <guido@python.org>
Sat, 13 Jan 2007 23:54:39 +0000 (23:54 +0000)
Tools/pybench/CommandLine.py
Tools/pybench/Dict.py
Tools/pybench/Exceptions.py
Tools/pybench/Lookups.py

index ddf958d86ad1e758b727c9a1c32efaf752c798b2..909ef02db98e8d6a0f10ee6fb01e3b8938a96e3e 100644 (file)
@@ -165,7 +165,7 @@ class Option:
     def __init__(self,name,help=None):
 
         if not name[:1] == '-':
-            raise TypeError,'option names must start with "-"'
+            raise TypeError('option names must start with "-"')
         if name[1:2] == '-':
             self.prefix = '--'
             self.name = name[2:]
@@ -324,30 +324,32 @@ class Application:
 
         # Append preset options
         for option in self.preset_options:
-            if not self.option_map.has_key(option.name):
+            if not option.name in self.option_map:
                 self.add_option(option)
 
         # Init .files list
         self.files = []
 
         # Start Application
+        rc = 0
         try:
             # Process startup
             rc = self.startup()
             if rc is not None:
-                raise SystemExit,rc
+                raise SystemExit(rc)
 
             # Parse command line
             rc = self.parse()
             if rc is not None:
-                raise SystemExit,rc
+                raise SystemExit(rc)
 
             # Start application
             rc = self.main()
             if rc is None:
                 rc = 0
 
-        except SystemExit as rc:
+        except SystemExit as rcException:
+            rc = rcException
             pass
 
         except KeyboardInterrupt:
@@ -367,7 +369,7 @@ class Application:
             print
             rc = 1
 
-        raise SystemExit,rc
+        raise SystemExit(rc)
 
     def add_option(self, option):
 
@@ -398,7 +400,7 @@ class Application:
             program. It defaults to 0 which usually means: OK.
 
         """
-        raise SystemExit, rc
+        raise SystemExit(rc)
 
     def parse(self):
 
@@ -459,7 +461,7 @@ class Application:
             except AttributeError:
                 if value == '':
                     # count the number of occurances
-                    if values.has_key(optionname):
+                    if optionname in values:
                         values[optionname] = values[optionname] + 1
                     else:
                         values[optionname] = 1
@@ -468,7 +470,7 @@ class Application:
             else:
                 rc = handler(value)
                 if rc is not None:
-                    raise SystemExit, rc
+                    raise SystemExit(rc)
 
         # Apply final file check (for backward compatibility)
         rc = self.check_files(self.files)
index 9cdd6826440a9ef4a42cefb81b043f6ab51630af..cb039b04e1f2a2b017a06d998f9840eb97c91836 100644 (file)
@@ -351,7 +351,7 @@ class SimpleDictManipulation(Test):
     def test(self):
 
         d = {}
-        has_key = d.has_key
+        has_key = lambda key: key in d
 
         for i in xrange(self.rounds):
 
@@ -498,7 +498,7 @@ class SimpleDictManipulation(Test):
     def calibrate(self):
 
         d = {}
-        has_key = d.has_key
+        has_key = lambda key: key in d
 
         for i in xrange(self.rounds):
             pass
index eff69c717b234012a6a0fb1ef6c1012fb4ee43a2..ab0fa0a22fc8bd9a0b143bd06fc7873b2e516078 100644 (file)
@@ -20,15 +20,15 @@ class TryRaiseExcept(Test):
             except:
                 pass
             try:
-                raise error,"something"
+                raise error("something")
             except:
                 pass
             try:
-                raise error,"something"
+                raise error("something")
             except:
                 pass
             try:
-                raise error,"something"
+                raise error("something")
             except:
                 pass
             try:
index f20e7da49c01a31f72a68d5b26ab2da8d929f380..e454a002b50b6cbc4a041fc9f3a7933e9e57f6b7 100644 (file)
@@ -774,11 +774,11 @@ class BuiltinMethodLookup(Test):
             l.sort
             l.sort
 
-            d.has_key
-            d.has_key
-            d.has_key
-            d.has_key
-            d.has_key
+            d.has_key
+            d.has_key
+            d.has_key
+            d.has_key
+            d.has_key
 
             d.items
             d.items
@@ -810,11 +810,11 @@ class BuiltinMethodLookup(Test):
             l.sort
             l.sort
 
-            d.has_key
-            d.has_key
-            d.has_key
-            d.has_key
-            d.has_key
+            d.has_key
+            d.has_key
+            d.has_key
+            d.has_key
+            d.has_key
 
             d.items
             d.items
@@ -846,11 +846,11 @@ class BuiltinMethodLookup(Test):
             l.sort
             l.sort
 
-            d.has_key
-            d.has_key
-            d.has_key
-            d.has_key
-            d.has_key
+            d.has_key
+            d.has_key
+            d.has_key
+            d.has_key
+            d.has_key
 
             d.items
             d.items
@@ -882,11 +882,11 @@ class BuiltinMethodLookup(Test):
             l.sort
             l.sort
 
-            d.has_key
-            d.has_key
-            d.has_key
-            d.has_key
-            d.has_key
+            d.has_key
+            d.has_key
+            d.has_key
+            d.has_key
+            d.has_key
 
             d.items
             d.items
@@ -918,11 +918,11 @@ class BuiltinMethodLookup(Test):
             l.sort
             l.sort
 
-            d.has_key
-            d.has_key
-            d.has_key
-            d.has_key
-            d.has_key
+            d.has_key
+            d.has_key
+            d.has_key
+            d.has_key
+            d.has_key
 
             d.items
             d.items