On Sun, Oct 20, 2013 at 8:56 PM, Martin Panter <vadmium+patch@gmail.com> wrote:
Hi Jeremy,
I just discovered another (but related) issue under Python 3 that you may not be aware of. There are places in the code, at least writedata() in util.py, that write to a text file, but do not specify an encoding. If you run the tests with LC_ALL=C, some of them fail in Python 3 (but succeed in Python 2) because they are writing non-ASCII characters.
The simplest solution might be to use codecs.open(encoding='utf8'), which is available in Python 2 and 3, and should continue to write the existing ASCII-only byte strings in Python 2.
Hi Martin, Sorry for the delayed response - I got swamped by another project. I thought about making the change you suggest, but decided against it because this feels like something that should be handled outside of the .py code. 99% of the time 'make' will be running the tests, so it seems simpler to tweak the invocation of Python rather than clutter up the framework. Perhaps we could add a check at startup (right next to the recently added "Python version is at least version 2.7") that will refuse to run any tests unless the locale is set appropriately? That seems less intrusive. In a similar vein, note that I left comments saying "required by 2.7" in all the places where specifying the encoding could not be avoided, but can (and should) be cleaned out once the jump is made to Python3. Anyway, I've got a little free time again, but I want to put aside the Python3 stuff for now and get back to what I was working on before I got distracted: unit tests for -Qk and -Qkk. After that I'll see if I can figure out why the "from __future__ import" didn't work. Jeremy