[Pkg-bazaar-commits] ./bzr/unstable r162: workaround for python2.3 difflib bug

mbp at sourcefrog.net mbp at sourcefrog.net
Fri Apr 10 07:51:16 UTC 2009


------------------------------------------------------------
revno: 162
committer: mbp at sourcefrog.net
timestamp: Mon 2005-04-04 19:50:24 +1000
message:
  workaround for python2.3 difflib bug
modified:
  NEWS
  bzrlib/commands.py
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2005-04-01 08:22:11 +0000
+++ b/NEWS	2005-04-04 09:50:24 +0000
@@ -14,6 +14,12 @@
     * Basic "bzr mv" support for renames!  (Not all scenarios work
       through the command at the moment, but the inventory support is
       there.)
+
+  PORTABILITY:
+
+    * Workaround for difflib bug in Python 2.3 that causes an
+      exception when comparing empty files.  Reported by Erik Toubro
+      Nielsen.
 
 bzr-0.0.2  "black cube"  2003-03-31
 

=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py	2005-04-01 08:22:11 +0000
+++ b/bzrlib/commands.py	2005-04-04 09:50:24 +0000
@@ -321,8 +321,13 @@
         # FIXME: Something about the diff format makes patch unhappy
         # with newly-added files.
 
-        def diffit(*a, **kw):
-            sys.stdout.writelines(difflib.unified_diff(*a, **kw))
+        def diffit(oldlines, newlines, **kw):
+            # FIXME: difflib is wrong if there is no trailing newline.
+
+            # Special workaround for Python2.3, where difflib fails if
+            # both sequences are empty.
+            if oldlines or newlines:
+                sys.stdout.writelines(difflib.unified_diff(oldlines, newlines, **kw))
             print
         
         if file_state in ['.', '?', 'I']:



More information about the Pkg-bazaar-commits mailing list