[merge] python 2.5 fixes

Martin Pool mbp at canonical.com
Fri Sep 22 04:17:54 BST 2006


Here's an updated patch including some (much) earlier work.

This also fixes a missing import of TestSkipped.

I'm +1 on merging Marien's ElementTree fixes too -- my python2.5 install
doesn't have celementtree.

Finally there is a case in a deprecated function log_exception in
trace.py that calls a method that no longer exists.  I'd rather just
remove log_exception but that shouldn't be done in freeze.

-- 
Martin
-------------- next part --------------
=== modified file 'NEWS'
--- NEWS	2006-09-22 00:24:07 +0000
+++ NEWS	2006-09-22 02:33:29 +0000
@@ -84,6 +84,10 @@
       paths. This may not work perfectly on all platforms, but has the best
       chance of working in the common case. (John Arbash Meinel, #56816)
 
+  PORTABILITY:
+
+    * Fixes to run on Python 2.5 (Brian M. Carlson, Martin Pool, Marien Zwart)
+
   INTERNALS:
 
     * TestCaseInTempDir now creates a separate directory for HOME, rather

=== modified file 'bzrlib/benchmarks/bench_sftp.py'
--- bzrlib/benchmarks/bench_sftp.py	2006-08-18 16:48:53 +0000
+++ bzrlib/benchmarks/bench_sftp.py	2006-09-22 03:06:55 +0000
@@ -21,7 +21,7 @@
     bzrdir,
     )
 from bzrlib.benchmarks import Benchmark
-from bzrlib.tests import test_sftp_transport
+from bzrlib.tests import test_sftp_transport, TestSkipped
 
 try:
     import paramiko

=== modified file 'bzrlib/errors.py'
--- bzrlib/errors.py	2006-09-21 23:06:54 +0000
+++ bzrlib/errors.py	2006-09-22 02:32:53 +0000
@@ -96,7 +96,7 @@
 class BzrError(StandardError):
     
     is_user_error = True
-    
+
     def __str__(self):
         # XXX: Should we show the exception class in 
         # exceptions that don't provide their own message?  
@@ -120,7 +120,11 @@
     # base classes should override the docstring with their human-
     # readable explanation
 
-    def __init__(self, **kwds):
+    def __init__(self, *args, **kwds):
+        # XXX: Use the underlying BzrError to always generate the args attribute
+        # if it doesn't exist.  We can't use super here, because exceptions are
+        # old-style classes in python2.4 (but new in 2.5).  --bmc, 20060426
+        BzrError.__init__(self, *args)
         for key, value in kwds.items():
             setattr(self, key, value)
 

=== modified file 'bzrlib/tests/test_command.py'
--- bzrlib/tests/test_command.py	2006-08-22 21:31:23 +0000
+++ bzrlib/tests/test_command.py	2006-09-22 02:32:53 +0000
@@ -21,7 +21,7 @@
     errors,
     )
 from bzrlib.commands import display_command
-from bzrlib.tests import TestCase
+from bzrlib.tests import TestCase, TestSkipped
 
 
 class TestCommands(TestCase):
@@ -49,6 +49,9 @@
     def test_unicode_option(self):
         # This error is actually thrown by optparse, when it
         # can't find the given option
+        import optparse
+        if optparse.__version__ == "1.5.3":
+            raise TestSkipped("optparse 1.5.3 can't handle unicode options")
         self.assertRaises(errors.BzrCommandError,
                           commands.run_bzr, ['log', u'--option\xb5'])
 

=== modified file 'bzrlib/trace.py'
--- bzrlib/trace.py	2006-09-21 23:06:54 +0000
+++ bzrlib/trace.py	2006-09-22 02:48:53 +0000
@@ -54,6 +54,7 @@
 import errno
 import os
 import sys
+import re
 import logging
 
 import bzrlib
@@ -168,9 +169,6 @@
     """
     if msg:
         error(msg)
-    else:
-        exc_str = format_exception_short(sys.exc_info())
-        error(exc_str)
     log_exception_quietly()
 
 



More information about the bazaar mailing list