[Python-modules-commits] [python-pynzb] 06/07: For Python 3, decode strings -> bytes as utf-8 for lxml.

Carl Suster arcresu-guest at moszumanska.debian.org
Mon Jan 9 01:19:04 UTC 2017


This is an automated email from the git hooks/post-receive script.

arcresu-guest pushed a commit to branch master
in repository python-pynzb.

commit c4ba8eb936bf721d6798929f81e51d0d72eed4b9
Author: Carl Suster <carl at contraflo.ws>
Date:   Mon Jan 9 12:16:48 2017 +1100

    For Python 3, decode strings -> bytes as utf-8 for lxml.
---
 debian/changelog | 1 +
 debian/rules     | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 04b868f..818db24 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -16,6 +16,7 @@ python-pynzb (0.1.0-3) UNRELEASED; urgency=medium
     Tests pass for Python 2 with only this change.
   * Move lxml to Suggests since there are fallbacks, but Build-Depend on it to
     run the tests.
+  * For Python 3, decode strings -> bytes as utf-8 for lxml.
 
  -- Carl Suster <carl at contraflo.ws>  Mon, 09 Jan 2017 00:37:36 +1100
 
diff --git a/debian/rules b/debian/rules
index 5b9c1e4..e7aefc0 100755
--- a/debian/rules
+++ b/debian/rules
@@ -4,7 +4,11 @@
 export PYBUILD_NAME=pynzb
 
 export PYBUILD_TEST_ARGS=pynzb/tests.py
-export PYBUILD_AFTER_BUILD_python3=2to3 -n -w {build_dir}/pynzb/
+# lxml expects a bytes object in Python 3 so we simply decode the string as
+# utf-8 for the Python 3 build. If this turns out to be problematic, we can
+# instead disable lxml support for the Python 3 build in pynzb/__init__.py and
+# rely on the standard library fallbacks for XML parsing.
+export PYBUILD_AFTER_BUILD_python3=2to3 -n -w {build_dir}/pynzb/; sed -i -e 's/StringIO/BytesIO/g' -e 's/BytesIO(xml)/BytesIO(bytes(xml,"utf-8"))/' {build_dir}/pynzb/lxml_nzb.py
 
 
 %:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-pynzb.git



More information about the Python-modules-commits mailing list