X Tutup
Skip to content

Commit 011ea47

Browse files
committed
Merge with 1.8 of pulldom.py:
Use types.UnicodeType if available, not type(u"").
1 parent 156c337 commit 011ea47

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Lib/xml/dom/pulldom.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import xml.sax
22
import xml.sax.handler
3+
import types
4+
5+
try:
6+
_StringTypes = [types.StringType, types.UnicodeType]
7+
except AttributeError:
8+
_StringTypes = [types.StringType]
39

410
START_ELEMENT = "START_ELEMENT"
511
END_ELEMENT = "END_ELEMENT"
@@ -235,7 +241,7 @@ def characters(self, chars):
235241
def parse(stream_or_string, parser=None, bufsize=None):
236242
if bufsize is None:
237243
bufsize = default_bufsize
238-
if type(stream_or_string) in [type(""), type(u"")]:
244+
if type(stream_or_string) in _StringTypes:
239245
stream = open(stream_or_string)
240246
else:
241247
stream = stream_or_string

0 commit comments

Comments
 (0)
X Tutup