"""
-__author__ = u"Stéphane Bidoul <sbi@skynet.be>"
+__author__ = "Stéphane Bidoul <sbi@skynet.be>"
__version__ = "0.3"
+import sys
import codecs
-from types import StringType, UnicodeType
-StringTypes = (StringType,UnicodeType)
+
+if sys.version_info[0] < 3:
+ __author__ = codecs.unicode_escape_decode(__author__)[0]
+
+ StringTypes = (str, unicode)
+else:
+ StringTypes = str
from xml.sax._exceptions import *
from xml.sax import xmlreader, saxutils
try:
import libxml2
-except ImportError, e:
+except ImportError:
raise SAXReaderNotAvailable("libxml2 not available: " \
- "import error was: %s" % e)
+ "import error was: %s" % sys.exc_info()[1])
class Locator(xmlreader.Locator):
"""SAX Locator adapter for libxml2.xmlTextReaderLocator"""
self.__parsing = 1
try:
# prepare source and create reader
- if type(source) in StringTypes:
+ if isinstance(source, StringTypes):
reader = libxml2.newTextReaderFilename(source)
else:
source = saxutils.prepare_input_source(source)