]> granicus.if.org Git - python/commitdiff
Merge with 1.8 of pulldom.py:
authorMartin v. Löwis <martin@v.loewis.de>
Thu, 28 Dec 2000 18:43:02 +0000 (18:43 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Thu, 28 Dec 2000 18:43:02 +0000 (18:43 +0000)
Use types.UnicodeType if available, not type(u"").

Lib/xml/dom/pulldom.py

index 7f5ef79739ad22b5baeae824821178348728d0da..5fc215ab73449672ebbbacd7cc1b4b106f0848a4 100644 (file)
@@ -1,5 +1,11 @@
 import xml.sax
 import xml.sax.handler
+import types
+
+try:
+    _StringTypes = [types.StringType, types.UnicodeType]
+except AttributeError:
+    _StringTypes = [types.StringType]
 
 START_ELEMENT = "START_ELEMENT"
 END_ELEMENT = "END_ELEMENT"
@@ -235,7 +241,7 @@ default_bufsize = (2 ** 14) - 20
 def parse(stream_or_string, parser=None, bufsize=None):
     if bufsize is None:
         bufsize = default_bufsize
-    if type(stream_or_string) in [type(""), type(u"")]:
+    if type(stream_or_string) in _StringTypes:
         stream = open(stream_or_string)
     else:
         stream = stream_or_string