diff options
author | Raphaël Hertzog <hertzog@debian.org> | 2015-08-25 21:55:54 +0200 |
---|---|---|
committer | Raphaël Hertzog <hertzog@debian.org> | 2015-08-25 21:55:54 +0200 |
commit | 7300193becde71a344c8ac0973dc290fa24d800d (patch) | |
tree | 6490c364e7764294c209e536d42f3d31d23ebc0d /python/drv_libxml2.py | |
parent | 3871a83a5f0aebd8c00879eab14fe901c93dbfcf (diff) | |
download | libxml2-7300193becde71a344c8ac0973dc290fa24d800d.tar.gz |
Imported Upstream version 2.9.1+dfsg1
Diffstat (limited to 'python/drv_libxml2.py')
-rw-r--r-- | python/drv_libxml2.py | 18 |
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) |