Переглянути джерело

- 3.0a3 broke Python 2.3 backwards compatibility.

Chris McDonough 17 роки тому
батько
коміт
a23e279fb5

+ 4 - 0
CHANGES.txt

@@ -1,3 +1,7 @@
+Next Release
+
+  - 3.0a3 broke Python 2.3 backwards compatibility.
+
 3.0a3
 
   - Supervisorctl now reports a better error message when the main

+ 4 - 1
src/supervisor/supervisord.py

@@ -286,7 +286,10 @@ def profile(cmd, globals, locals, sort_order, callers):
     import tempfile
     fd, fn = tempfile.mkstemp()
     try:
-        profile.runctx(cmd, globals, locals, fn)
+        if hasattr(profile, 'runctx'):
+            profile.runctx(cmd, globals, locals, fn)
+        else:
+            raise NotImplementedError('No profiling support under Python 2.3')
         stats = pstats.Stats(fn)
         stats.strip_dirs()
         # calls,time,cumulative and cumulative,calls,time are useful

+ 22 - 21
src/supervisor/tests/test_supervisord.py

@@ -35,27 +35,28 @@ class EntryPointTests(unittest.TestCase):
         output = new_stdout.getvalue()
         self.failUnless(output.find('supervisord started') != 1, output)
 
-    def test_main_profile(self):
-        from supervisor.supervisord import main
-        conf = os.path.join(
-            os.path.abspath(os.path.dirname(__file__)), 'fixtures',
-            'donothing.conf')
-        import StringIO
-        new_stdout = StringIO.StringIO()
-        old_stdout = sys.stdout
-        try:
-            tempdir = tempfile.mkdtemp()
-            log = os.path.join(tempdir, 'log')
-            pid = os.path.join(tempdir, 'pid')
-            sys.stdout = new_stdout
-            main(args=['-c', conf, '-l', log, '-j', pid, '-n',
-                       '--profile_options=cumulative,calls'], test=True)
-        finally:
-            sys.stdout = old_stdout
-            shutil.rmtree(tempdir)
-        output = new_stdout.getvalue()
-        self.failUnless(output.find('cumulative time, call count') != -1,
-                        output)
+    if sys.version_info[:2] >= (2, 4):
+        def test_main_profile(self):
+            from supervisor.supervisord import main
+            conf = os.path.join(
+                os.path.abspath(os.path.dirname(__file__)), 'fixtures',
+                'donothing.conf')
+            import StringIO
+            new_stdout = StringIO.StringIO()
+            old_stdout = sys.stdout
+            try:
+                tempdir = tempfile.mkdtemp()
+                log = os.path.join(tempdir, 'log')
+                pid = os.path.join(tempdir, 'pid')
+                sys.stdout = new_stdout
+                main(args=['-c', conf, '-l', log, '-j', pid, '-n',
+                           '--profile_options=cumulative,calls'], test=True)
+            finally:
+                sys.stdout = old_stdout
+                shutil.rmtree(tempdir)
+            output = new_stdout.getvalue()
+            self.failUnless(output.find('cumulative time, call count') != -1,
+                            output)
 
 class SupervisordTests(unittest.TestCase):
     def tearDown(self):

+ 2 - 2
src/supervisor/xmlrpc.py

@@ -544,7 +544,7 @@ try:
         "dateTime.iso8601": lambda x: make_datetime(x.text),
         "array": lambda x: [v.text for v in x],
         "data": lambda x: x[0].text,
-        "struct": lambda x: dict((k.text or "", v.text) for k, v in x),
+        "struct": lambda x: dict([(k.text or "", v.text) for k, v in x]),
         "base64": lambda x: decodestring(x.text or ""),
         "value": lambda x: x[0].text,
         "param": lambda x: x[0].text,
@@ -561,7 +561,7 @@ try:
             elif elem.tag == "methodName":
                 method = elem.text
             elif elem.tag == "params":
-                params = tuple(v.text for v in elem)
+                params = tuple([v.text for v in elem])
         return params, method
 
 except ImportError: