rolled back to 2.9.2 because 2.9.4 doesn't work with XML validator
[platform/upstream/libxml2.git] / python / drv_libxml2.py
index 71b1c67..c2ec3e2 100644 (file)
@@ -44,18 +44,8 @@ if sys.version_info[0] < 3:
     __author__  = codecs.unicode_escape_decode(__author__)[0]
 
     StringTypes = (str, unicode)
-    # libxml2 returns strings as UTF8
-    _decoder = codecs.lookup("utf8")[1]
-    def _d(s):
-        if s is None:
-            return s
-        else:
-            return _decoder(s)[0]
 else:
     StringTypes = str
-    # s is Unicode `str` already
-    def _d(s):
-        return s
 
 from xml.sax._exceptions import *
 from xml.sax import xmlreader, saxutils
@@ -71,6 +61,14 @@ from xml.sax.handler import \
      property_dom_node, \
      property_xml_string
 
+# libxml2 returns strings as UTF8
+_decoder = codecs.lookup("utf8")[1]
+def _d(s):
+    if s is None:
+        return s
+    else:
+        return _decoder(s)[0]
+
 try:
     import libxml2
 except ImportError: