[Python-modules-commits] [pyxb] 04/10: open files with UTF-8 encoding on Python3

Michael Fladischer fladi at moszumanska.debian.org
Tue Sep 27 11:19:09 UTC 2016


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

fladi pushed a commit to branch master
in repository pyxb.

commit a46b41bce0a5839cffd6954b61c2153f671dd1c5
Author: Michael Fladischer <FladischerMichael at fladi.at>
Date:   Thu Oct 8 13:33:24 2015 -0700

    open files with UTF-8 encoding on Python3
    
     Python3 would open the test files as raw bytes if no encoding is specified,
     leading to UnicodeDecodeError exceptions.
    Last-Update: 2014-10-24
    Forwarded: no
    
    Patch-Name: 02-setup_open_unicode.patch
---
 setup.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index 4b94027..d429ab7 100755
--- a/setup.py
+++ b/setup.py
@@ -18,6 +18,7 @@ import stat
 import re
 import datetime
 import logging
+import io
 
 from distutils.core import setup, Command
 
@@ -123,7 +124,10 @@ class test (Command):
                     number += 1
 
                 # Read the test source in and compile it
-                rv = compile(open(fn).read(), test_name, 'exec')
+                if sys.version_info > (3,):
+                    rv = compile(io.open(fn, encoding='utf-8').read(), test_name, 'exec')
+                else:
+                    rv = compile(open(fn).read(), test_name, 'exec')
                 state = 'evaluate'
 
                 # Make a copy of the globals array so we don't

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



More information about the Python-modules-commits mailing list