Package: python-meld3
Version: 0.6.5-3
Severity: important
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu ubuntu-patch oneiric

When built for Python 2.7, python-meld3 is broken:

  $ python
  Python 2.7.2+ (default, Aug 16 2011, 07:29:45)
  [GCC 4.6.1] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import meld3
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/lib/pymodules/python2.7/meld3/__init__.py", line 2, in <module>
      from meld3 import parse_xml
    File "/usr/lib/pymodules/python2.7/meld3/meld3.py", line 27, in <module>
      from xml.etree.ElementTree import fixtag
  ImportError: cannot import name fixtag

This has been reported in a few other distributions' bug tracking
systems:

  https://bugs.launchpad.net/ubuntu/+source/python-meld3/+bug/749880
  https://bugzilla.redhat.com/show_bug.cgi?id=652890

... and fixed upstream:

  
https://github.com/Supervisor/meld3/commit/afe92611ee5959d1105a37c4403c99520e24c4ae

Jessica McKellar extracted the relevant patch and applied it to the
Ubuntu package.  Here's a diff.

  * Apply most of commit afe92611 upstream to make the package compatible
    with Python 2.7. (LP: #749880)

 -- Jessica McKellar <jesst...@mit.edu>  Sun, 02 Oct 2011 16:08:55 -0400

--- python-meld3-0.6.5.orig/meld3/meld3.py
+++ python-meld3-0.6.5/meld3/meld3.py
@@ -3,6 +3,7 @@
 import re
 import types
 import mimetools
+import string
 from StringIO import StringIO
 
 try:
@@ -24,10 +25,32 @@
     from xml.etree.ElementTree import QName
     from xml.etree.ElementTree import _raise_serialization_error
     from xml.etree.ElementTree import _namespace_map
-    from xml.etree.ElementTree import fixtag
     from xml.etree.ElementTree import parse as et_parse
     from xml.etree.ElementTree import ElementPath
 
+    try:
+        from xml.etree.ElementTree import fixtag
+    except:
+        def fixtag(tag, namespaces):
+            # given a decorated tag (of the form {uri}tag), return prefixed
+            # tag and namespace declaration, if any
+            if isinstance(tag, QName):
+                tag = tag.text
+            namespace_uri, tag = string.split(tag[1:], "}", 1)
+            prefix = namespaces.get(namespace_uri)
+            if prefix is None:
+                prefix = _namespace_map.get(namespace_uri)
+                if prefix is None:
+                    prefix = "ns%d" % len(namespaces)
+                namespaces[namespace_uri] = prefix
+                if prefix == "xml":
+                    xmlns = None
+                else:
+                    xmlns = ("xmlns:%s" % prefix, namespace_uri)
+            else:
+                xmlns = None
+            return "%s:%s" % (prefix, tag), xmlns
+
 # HTMLTreeBuilder does not exist in python 2.5 standard elementtree
 from HTMLParser import HTMLParser
 AUTOCLOSE = "p", "li", "tr", "th", "td", "head", "body"
--- python-meld3-0.6.5.orig/meld3/test_meld3.py
+++ python-meld3-0.6.5/meld3/test_meld3.py
@@ -1,6 +1,7 @@
 import unittest
 from StringIO import StringIO
 import re
+import sys
 
 _SIMPLE_XML = r"""<?xml version="1.0"?>
 <root xmlns:meld="http://www.plope.com/software/meld3";>
@@ -1671,9 +1672,13 @@
 </html>"""
 
     def test_unknown_entity(self):
-        from xml.parsers import expat
-        self.assertRaises(expat.error, self._parse,
-                          '<html><head></head><body>&fleeb;</body></html>')
+        if sys.version_info[:3] >= (2,7,0):
+            self.assertRaises(SyntaxError, self._parse,
+                              '<html><head></head><body>&fleeb;</body></html>')
+        else:
+            from xml.parsers import expat
+            self.assertRaises(expat.error, self._parse,
+                              '<html><head></head><body>&fleeb;</body></html>')
 
     def test_content_nostructure(self):
         root = self._parse(_SIMPLE_XML)

Thanks,

-- 
Colin Watson                                       [cjwat...@ubuntu.com]



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to