Commits

Ronny Pfannschmidt committed 60d2757

patches

Comments (0)

Files changed (3)

 decode-errors
 capture-bytes
+xmlgen-real-unicode
+xmlgen-object
+# HG changeset patch
+# Parent 1b68b3728002cdbfd2ac00cc7befa65bc40aed28
+special case for tags in xmlgen to work for the object tag
+
+diff --git a/py/_xmlgen.py b/py/_xmlgen.py
+--- a/py/_xmlgen.py
++++ b/py/_xmlgen.py
+@@ -117,12 +117,16 @@ class SimpleUnicodeVisitor(object):
+         try:
+             visitmethod = self.cache[cls]
+         except KeyError:
+-            for subclass in cls.__mro__:
+-                visitmethod = getattr(self, subclass.__name__, None)
+-                if visitmethod is not None:
+-                    break
++            if Tag in cls.__mro__:
++                #special case to avoid trouble with the tag name object
++                visitmethod = self.Tag
+             else:
+-                visitmethod = self.object
++                for subclass in cls.__mro__:
++                    visitmethod = getattr(self, subclass.__name__, None)
++                    if visitmethod is not None:
++                        break
++                else:
++                    visitmethod = self.object
+             self.cache[cls] = visitmethod
+         visitmethod(node)
+ 
+diff --git a/testing/root/test_xmlgen.py b/testing/root/test_xmlgen.py
+--- a/testing/root/test_xmlgen.py
++++ b/testing/root/test_xmlgen.py
+@@ -134,3 +134,6 @@ def test_inline():
+     assert (h.unicode(indent=2) ==
+             '<div><span>foo</span><span>bar</span></div>')
+ 
++def test_objct_tags():
++    o = html.object(html.object())
++    assert o.unicode() == '<object><object></object></object>'

xmlgen-real-unicode

+# HG changeset patch
+# Parent e17bdc9a601aa4de404df62d66d0decfcf2dcc71
+add missung unicode transform to the xml serialization
+
+diff --git a/py/_xmlgen.py b/py/_xmlgen.py
+--- a/py/_xmlgen.py
++++ b/py/_xmlgen.py
+@@ -52,7 +52,7 @@ class Tag(list):
+     def unicode(self, indent=2):
+         l = []
+         SimpleUnicodeVisitor(l.append, indent).visit(self)
+-        return "".join(l)
++        return u("").join(l)
+ 
+     def __repr__(self):
+         name = self.__class__.__name__