Merged revisions 83140-83141 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r83140 | alexander.belopolsky | 2010-07-25 11:02:55 -0400 (Sun, 25 Jul 2010) | 5 lines

  Issue #9315: Renamed test_trace to test_sys_settrace and
  test_profilehooks to test_sys_setprofile so that test_trace can be
  used for testing the trace module and for naming consistency.
........
  r83141 | alexander.belopolsky | 2010-07-25 11:05:42 -0400 (Sun, 25 Jul 2010) | 1 line

  Corrected comments on where settrace and setprofile are tested.
........
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index b17827c..53cdcb2 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -205,8 +205,8 @@
             # can't check more than the type, as the user might have changed it
             self.assertIsInstance(sys.getdefaultencoding(), str)
 
-    # testing sys.settrace() is done in test_trace.py
-    # testing sys.setprofile() is done in test_profile.py
+    # testing sys.settrace() is done in test_sys_settrace.py
+    # testing sys.setprofile() is done in test_sys_setprofile.py
 
     def test_setcheckinterval(self):
         self.assertRaises(TypeError, sys.setcheckinterval)
diff --git a/Lib/test/test_profilehooks.py b/Lib/test/test_sys_setprofile.py
similarity index 95%
rename from Lib/test/test_profilehooks.py
rename to Lib/test/test_sys_setprofile.py
index 4083d11..54267a0 100644
--- a/Lib/test/test_profilehooks.py
+++ b/Lib/test/test_sys_setprofile.py
@@ -2,7 +2,7 @@
 import sys
 import unittest
 
-from test import test_support
+from test import support
 
 class TestGetProfile(unittest.TestCase):
     def setUp(self):
@@ -47,7 +47,7 @@
 
     def get_events(self):
         """Remove calls to add_event()."""
-        disallowed = [ident(self.add_event.im_func), ident(ident)]
+        disallowed = [ident(self.add_event.__func__), ident(ident)]
         self.frames = None
 
         return [item for item in self.events if item[2] not in disallowed]
@@ -110,7 +110,7 @@
 
     def test_exception(self):
         def f(p):
-            1./0
+            1/0
         f_ident = ident(f)
         self.check_events(f, [(1, 'call', f_ident),
                               (1, 'return', f_ident),
@@ -118,7 +118,7 @@
 
     def test_caught_exception(self):
         def f(p):
-            try: 1./0
+            try: 1/0
             except: pass
         f_ident = ident(f)
         self.check_events(f, [(1, 'call', f_ident),
@@ -127,7 +127,7 @@
 
     def test_caught_nested_exception(self):
         def f(p):
-            try: 1./0
+            try: 1/0
             except: pass
         f_ident = ident(f)
         self.check_events(f, [(1, 'call', f_ident),
@@ -136,7 +136,7 @@
 
     def test_nested_exception(self):
         def f(p):
-            1./0
+            1/0
         f_ident = ident(f)
         self.check_events(f, [(1, 'call', f_ident),
                               # This isn't what I expected:
@@ -147,7 +147,7 @@
 
     def test_exception_in_except_clause(self):
         def f(p):
-            1./0
+            1/0
         def g(p):
             try:
                 f(p)
@@ -166,7 +166,7 @@
 
     def test_exception_propogation(self):
         def f(p):
-            1./0
+            1/0
         def g(p):
             try: f(p)
             finally: p.add_event("falling through")
@@ -181,8 +181,8 @@
 
     def test_raise_twice(self):
         def f(p):
-            try: 1./0
-            except: 1./0
+            try: 1/0
+            except: 1/0
         f_ident = ident(f)
         self.check_events(f, [(1, 'call', f_ident),
                               (1, 'return', f_ident),
@@ -190,7 +190,7 @@
 
     def test_raise_reraise(self):
         def f(p):
-            try: 1./0
+            try: 1/0
             except: raise
         f_ident = ident(f)
         self.check_events(f, [(1, 'call', f_ident),
@@ -207,7 +207,7 @@
 
     def test_distant_exception(self):
         def f():
-            1./0
+            1/0
         def g():
             f()
         def h():
@@ -292,7 +292,7 @@
 
     def test_basic_exception(self):
         def f(p):
-            1./0
+            1/0
         f_ident = ident(f)
         self.check_events(f, [(1, 'call', f_ident),
                               (1, 'return', f_ident),
@@ -300,7 +300,7 @@
 
     def test_caught_exception(self):
         def f(p):
-            try: 1./0
+            try: 1/0
             except: pass
         f_ident = ident(f)
         self.check_events(f, [(1, 'call', f_ident),
@@ -309,7 +309,7 @@
 
     def test_distant_exception(self):
         def f():
-            1./0
+            1/0
         def g():
             f()
         def h():
@@ -340,7 +340,7 @@
     if hasattr(function, "f_code"):
         code = function.f_code
     else:
-        code = function.func_code
+        code = function.__code__
     return code.co_firstlineno, code.co_name
 
 
@@ -357,7 +357,7 @@
     except TypeError:
         pass
     else:
-        raise test_support.TestFailed(
+        raise support.TestFailed(
             'sys.setprofile() did not raise TypeError')
 
     if p is None:
@@ -374,7 +374,7 @@
 
 
 def test_main():
-    test_support.run_unittest(
+    support.run_unittest(
         TestGetProfile,
         ProfileHookTestCase,
         ProfileSimulatorTestCase
diff --git a/Lib/test/test_trace.py b/Lib/test/test_sys_settrace.py
similarity index 95%
rename from Lib/test/test_trace.py
rename to Lib/test/test_sys_settrace.py
index df8c56f..43134e9 100644
--- a/Lib/test/test_trace.py
+++ b/Lib/test/test_sys_settrace.py
@@ -1,6 +1,6 @@
 # Testing the line trace facility.
 
-from test import test_support
+from test import support
 import unittest
 import sys
 import difflib
@@ -98,7 +98,7 @@
 def test_raise():
     try:
         raises()
-    except Exception, exc:
+    except Exception as exc:
         x = 1
 
 test_raise.events = [(0, 'call'),
@@ -128,7 +128,7 @@
 def settrace_and_raise(tracefunc):
     try:
         _settrace_and_raise(tracefunc)
-    except RuntimeError, exc:
+    except RuntimeError as exc:
         pass
 
 settrace_and_raise.events = [(2, 'exception'),
@@ -269,7 +269,7 @@
         sys.settrace(tracer.trace)
         func()
         sys.settrace(None)
-        self.compare_events(func.func_code.co_firstlineno,
+        self.compare_events(func.__code__.co_firstlineno,
                             tracer.events, events)
 
     def run_test(self, func):
@@ -279,7 +279,7 @@
         tracer = Tracer()
         func(tracer.trace)
         sys.settrace(None)
-        self.compare_events(func.func_code.co_firstlineno,
+        self.compare_events(func.__code__.co_firstlineno,
                             tracer.events, func.events)
 
     def set_and_retrieve_none(self):
@@ -379,9 +379,10 @@
              (3, 'return')])
 
     def test_16_blank_lines(self):
-        exec("def f():\n" + "\n" * 256 + "    pass")
+        namespace = {}
+        exec("def f():\n" + "\n" * 256 + "    pass", namespace)
         self.run_and_compare(
-            f,
+            namespace["f"],
             [(0, 'call'),
              (257, 'line'),
              (257, 'return')])
@@ -401,7 +402,7 @@
         we're testing, so that the 'exception' trace event fires."""
         if self.raiseOnEvent == 'exception':
             x = 0
-            y = 1 // x
+            y = 1/x
         else:
             return 1
 
@@ -410,7 +411,7 @@
         handled OK."""
         self.raiseOnEvent = event
         try:
-            for i in xrange(sys.getrecursionlimit() + 1):
+            for i in range(sys.getrecursionlimit() + 1):
                 sys.settrace(self.trace)
                 try:
                     self.f()
@@ -434,12 +435,12 @@
     def test_trash_stack(self):
         def f():
             for i in range(5):
-                print i  # line tracing will raise an exception at this line
+                print(i)  # line tracing will raise an exception at this line
 
         def g(frame, why, extra):
             if (why == 'line' and
-                frame.f_lineno == f.func_code.co_firstlineno + 2):
-                raise RuntimeError, "i am crashing"
+                frame.f_lineno == f.__code__.co_firstlineno + 2):
+                raise RuntimeError("i am crashing")
             return g
 
         sys.settrace(g)
@@ -469,7 +470,7 @@
         self.done = False
 
     def trace(self, frame, event, arg):
-        if not self.done and frame.f_code == self.function.func_code:
+        if not self.done and frame.f_code == self.function.__code__:
             firstLine = frame.f_code.co_firstlineno
             if event == 'line' and frame.f_lineno == firstLine + self.jumpFrom:
                 # Cope with non-integer self.jumpTo (because of
@@ -557,7 +558,7 @@
     try:
         output.append(2)
         output.append(3)
-    except ValueError, e:
+    except ValueError as e:
         output.append('after' in str(e))
 
 no_jump_too_far_forwards.jump = (3, 6)
@@ -567,7 +568,7 @@
     try:
         output.append(2)
         output.append(3)
-    except ValueError, e:
+    except ValueError as e:
         output.append('before' in str(e))
 
 no_jump_too_far_backwards.jump = (3, -1)
@@ -597,7 +598,7 @@
 def no_jump_to_except_3(output):
     try:
         output.append(2)
-    except ValueError, e:
+    except ValueError as e:
         output.append('except' in str(e))
 
 no_jump_to_except_3.jump = (2, 3)
@@ -606,7 +607,7 @@
 def no_jump_to_except_4(output):
     try:
         output.append(2)
-    except (ValueError, RuntimeError), e:
+    except (ValueError, RuntimeError) as e:
         output.append('except' in str(e))
 
 no_jump_to_except_4.jump = (2, 3)
@@ -617,7 +618,7 @@
         output.append(2)
         for i in 1, 2:
             output.append(4)
-    except ValueError, e:
+    except ValueError as e:
         output.append('into' in str(e))
 
 no_jump_forwards_into_block.jump = (2, 4)
@@ -628,7 +629,7 @@
         for i in 1, 2:
             output.append(3)
         output.append(4)
-    except ValueError, e:
+    except ValueError as e:
         output.append('into' in str(e))
 
 no_jump_backwards_into_block.jump = (4, 3)
@@ -641,7 +642,7 @@
             x = 1
         finally:
             output.append(6)
-    except ValueError, e:
+    except ValueError as e:
         output.append('finally' in str(e))
 
 no_jump_into_finally_block.jump = (4, 6)
@@ -654,7 +655,7 @@
         finally:
             output.append(5)
             output.append(6)
-    except ValueError, e:
+    except ValueError as e:
         output.append('finally' in str(e))
 
 no_jump_out_of_finally_block.jump = (5, 1)
@@ -664,7 +665,7 @@
 def no_jump_to_non_integers(output):
     try:
         output.append(2)
-    except ValueError, e:
+    except ValueError as e:
         output.append('integer' in str(e))
 
 no_jump_to_non_integers.jump = (2, "Spam")
@@ -676,14 +677,14 @@
     try:
         previous_frame = sys._getframe().f_back
         previous_frame.f_lineno = previous_frame.f_lineno
-    except ValueError, e:
+    except ValueError as e:
         # This is the exception we wanted; make sure the error message
         # talks about trace functions.
         if 'trace' not in str(e):
             raise
     else:
         # Something's wrong - the expected exception wasn't raised.
-        raise RuntimeError, "Trace-function-less jump failed to fail"
+        raise RuntimeError("Trace-function-less jump failed to fail")
 
 
 class JumpTestCase(unittest.TestCase):
@@ -768,18 +769,18 @@
 output.append(4)
 """, "<fake module>", "exec")
         class fake_function:
-            func_code = code
+            __code__ = code
             jump = (2, 0)
         tracer = JumpTracer(fake_function)
         sys.settrace(tracer.trace)
         namespace = {"output": []}
-        exec code in namespace
+        exec(code, namespace)
         sys.settrace(None)
         self.compare_jump_output([2, 3, 2, 3, 4], namespace["output"])
 
 
 def test_main():
-    test_support.run_unittest(
+    support.run_unittest(
         TraceTestCase,
         RaisingTraceFuncTestCase,
         JumpTestCase