Merge with 1.8 of pulldom.py:

Use types.UnicodeType if available, not type(u"").
This commit is contained in:
Martin v. Löwis 2000-12-28 18:43:02 +00:00
parent 156c337f66
commit 011ea47577
1 changed files with 7 additions and 1 deletions

View 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