[libxml2] python 3: libxml2.c wrappers create Unicode str already
- From: Daniel Veillard <veillard src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxml2] python 3: libxml2.c wrappers create Unicode str already
- Date: Fri, 11 Mar 2016 08:22:20 +0000 (UTC)
commit 65112cb36aa56bb27697c38ff52c1489cc21cba5
Author: Michael Stahl <mstahl redhat com>
Date: Mon Jan 18 12:46:41 2016 +0100
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".
python/drv_libxml2.py | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/python/drv_libxml2.py b/python/drv_libxml2.py
index c2ec3e2..71b1c67 100644
--- a/python/drv_libxml2.py
+++ b/python/drv_libxml2.py
@@ -44,8 +44,18 @@ if sys.version_info[0] < 3:
__author__ = codecs.unicode_escape_decode(__author__)[0]
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:
StringTypes = str
+ # s is Unicode `str` already
+ def _d(s):
+ return s
from xml.sax._exceptions import *
from xml.sax import xmlreader, saxutils
@@ -61,14 +71,6 @@ from xml.sax.handler import \
property_dom_node, \
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:
import libxml2
except ImportError:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]