diff options
author | Aron Xu <aron@debian.org> | 2015-09-21 22:58:06 +0800 |
---|---|---|
committer | Aron Xu <aron@debian.org> | 2015-09-21 22:58:06 +0800 |
commit | 2ee13d9e464a1f5daccaff58f5d09d36b7c4f667 (patch) | |
tree | b022967f880b7fb1e56c8cc4c3f200d6ffbc9efd /python/drv_libxml2.py | |
parent | 7300193becde71a344c8ac0973dc290fa24d800d (diff) | |
download | libxml2-upstream.tar.gz |
Revert "Imported Upstream version 2.9.1+dfsg1"upstream
This reverts commit 7300193becde71a344c8ac0973dc290fa24d800d.
Diffstat (limited to 'python/drv_libxml2.py')
-rw-r--r-- | python/drv_libxml2.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/python/drv_libxml2.py b/python/drv_libxml2.py index e43fb1d..c2ec3e2 100644 --- a/python/drv_libxml2.py +++ b/python/drv_libxml2.py @@ -34,12 +34,18 @@ TODO """ -__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 @@ -65,9 +71,9 @@ def _d(s): 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""" @@ -134,7 +140,7 @@ class LibXml2Reader(xmlreader.XMLReader): 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) |