summaryrefslogtreecommitdiff
path: root/python/drv_libxml2.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/drv_libxml2.py')
-rw-r--r--python/drv_libxml2.py18
1 files changed, 6 insertions, 12 deletions
diff --git a/python/drv_libxml2.py b/python/drv_libxml2.py
index c2ec3e2..e43fb1d 100644
--- a/python/drv_libxml2.py
+++ b/python/drv_libxml2.py
@@ -34,18 +34,12 @@ TODO
"""
-__author__ = "Stéphane Bidoul <sbi@skynet.be>"
+__author__ = u"Stéphane Bidoul <sbi@skynet.be>"
__version__ = "0.3"
-import sys
import codecs
-
-if sys.version_info[0] < 3:
- __author__ = codecs.unicode_escape_decode(__author__)[0]
-
- StringTypes = (str, unicode)
-else:
- StringTypes = str
+from types import StringType, UnicodeType
+StringTypes = (StringType,UnicodeType)
from xml.sax._exceptions import *
from xml.sax import xmlreader, saxutils
@@ -71,9 +65,9 @@ def _d(s):
try:
import libxml2
-except ImportError:
+except ImportError, e:
raise SAXReaderNotAvailable("libxml2 not available: " \
- "import error was: %s" % sys.exc_info()[1])
+ "import error was: %s" % e)
class Locator(xmlreader.Locator):
"""SAX Locator adapter for libxml2.xmlTextReaderLocator"""
@@ -140,7 +134,7 @@ class LibXml2Reader(xmlreader.XMLReader):
self.__parsing = 1
try:
# prepare source and create reader
- if isinstance(source, StringTypes):
+ if type(source) in StringTypes:
reader = libxml2.newTextReaderFilename(source)
else:
source = saxutils.prepare_input_source(source)