mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +03:00
python 3: libxml2.c wrappers create Unicode str already
... so stop decoding these, which only results in "TypeError: 'str' does not support the buffer interface".
This commit is contained in:
committed by
Daniel Veillard
parent
dfbacd4f41
commit
65112cb36a
@ -44,8 +44,18 @@ if sys.version_info[0] < 3:
|
|||||||
__author__ = codecs.unicode_escape_decode(__author__)[0]
|
__author__ = codecs.unicode_escape_decode(__author__)[0]
|
||||||
|
|
||||||
StringTypes = (str, unicode)
|
StringTypes = (str, unicode)
|
||||||
|
# libxml2 returns strings as UTF8
|
||||||
|
_decoder = codecs.lookup("utf8")[1]
|
||||||
|
def _d(s):
|
||||||
|
if s is None:
|
||||||
|
return s
|
||||||
|
else:
|
||||||
|
return _decoder(s)[0]
|
||||||
else:
|
else:
|
||||||
StringTypes = str
|
StringTypes = str
|
||||||
|
# s is Unicode `str` already
|
||||||
|
def _d(s):
|
||||||
|
return s
|
||||||
|
|
||||||
from xml.sax._exceptions import *
|
from xml.sax._exceptions import *
|
||||||
from xml.sax import xmlreader, saxutils
|
from xml.sax import xmlreader, saxutils
|
||||||
@ -61,14 +71,6 @@ from xml.sax.handler import \
|
|||||||
property_dom_node, \
|
property_dom_node, \
|
||||||
property_xml_string
|
property_xml_string
|
||||||
|
|
||||||
# libxml2 returns strings as UTF8
|
|
||||||
_decoder = codecs.lookup("utf8")[1]
|
|
||||||
def _d(s):
|
|
||||||
if s is None:
|
|
||||||
return s
|
|
||||||
else:
|
|
||||||
return _decoder(s)[0]
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import libxml2
|
import libxml2
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
Reference in New Issue
Block a user