~ubuntu-branches/ubuntu/wily/libxml2/wily-proposed

« back to all changes in this revision

Viewing changes to python/drv_libxml2.py

  • Committer: Package Import Robot
  • Author(s): Aron Xu
  • Date: 2014-10-26 07:04:50 UTC
  • mfrom: (43.2.7 sid)
  • Revision ID: package-import@ubuntu.com-20141026070450-rmcqvcqn8peeuebs
Tags: 2.9.2+dfsg1-1
* New upstream release (Closes: #765722, CVE-2014-3660)
* Remove no-longer-needed upstream patches
* Update distro patch
* Std-ver: 3.9.5 -> 3.9.6, no change.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
"""
36
36
 
37
 
__author__  = u"St�phane Bidoul <sbi@skynet.be>"
 
37
__author__  = "St�phane Bidoul <sbi@skynet.be>"
38
38
__version__ = "0.3"
39
39
 
 
40
import sys
40
41
import codecs
41
 
from types import StringType, UnicodeType
42
 
StringTypes = (StringType,UnicodeType)
 
42
 
 
43
if sys.version_info[0] < 3:
 
44
    __author__  = codecs.unicode_escape_decode(__author__)[0]
 
45
 
 
46
    StringTypes = (str, unicode)
 
47
else:
 
48
    StringTypes = str
43
49
 
44
50
from xml.sax._exceptions import *
45
51
from xml.sax import xmlreader, saxutils
65
71
 
66
72
try:
67
73
    import libxml2
68
 
except ImportError, e:
 
74
except ImportError:
69
75
    raise SAXReaderNotAvailable("libxml2 not available: " \
70
 
                                "import error was: %s" % e)
 
76
                                "import error was: %s" % sys.exc_info()[1])
71
77
 
72
78
class Locator(xmlreader.Locator):
73
79
    """SAX Locator adapter for libxml2.xmlTextReaderLocator"""
134
140
        self.__parsing = 1
135
141
        try:
136
142
            # prepare source and create reader
137
 
            if type(source) in StringTypes:
 
143
            if isinstance(source, StringTypes):
138
144
                reader = libxml2.newTextReaderFilename(source)
139
145
            else:
140
146
                source = saxutils.prepare_input_source(source)