Repository navigation
[MRG] Explicitly specify utf8 encoding for authors.csv - #1737
Conversation
|
thanks for this @wltrimbl!
happy to fix - but isn't master up to date with v2.1.1?
our CI builds python2.7 - what do you think is the problem?
|
Codecov Report
@@ Coverage Diff @@
## master #1737 +/- ##
======================================
Coverage 0.05% 0.05%
======================================
Files 90 90
Lines 11336 11336
Branches 2992 2992
======================================
Hits 6 6
Misses 11330 11330Continue to review full report at Codecov.
|
|
Best guess for the 2.7 build failures: subtle and unimportant differences in environment. The Dockerfile in The dockerfile uses ubnutu-wily, while CI uses debian-trusty. This suggests that when publishing Dockerfiles that you want to work for a few years git clone && build is not the best idea; specifying a version of the repo in the Dockerfile confers stability. |
|
On Sun, Jun 25, 2017 at 09:41:51AM -0700, Will Trimble wrote:
Best guess for the 2.7 build failures: subtle and unimportant differences in environment.
The Dockerfile in
https://github.com/wltrimbl/2016-sourmash-tax/tree/master/make_khmer
does not build for June 2017 versions of khmer (though it can be rescued by specifying an older version tag)
see also #1333.
2016-sourmash-tax is pretty out of date at this point.
This suggests that when publishing Dockerfiles that you want to work for a few years git clone && build is not the best idea; specifying a version of the repo in the Dockerfile confers stability.
yes, when we publish dockerfiles that we want to work for a few years we will
do that :)
|
|
There are two problems (I think) and they only appear if you have a terminal that does not have (or claims not to have) unicode support. This snippet can read in the authors on python 2 and 3 (when I unset In [5]: with codecs.open('authors.csv', 'rb', encoding='utf-8') as csvin:
...: authors = csvin.readlines()
...: authors = [a.strip().split(',') for a in authors]
...: authorstr = ', '.join([row[0] for row in authors])the encoding specifies the encoding of the file, so I think that shouldn't change between versions. The problem is that when python thinks the terminal does not support unicode it will use ascii when printing (which is what |
|
Maybe the way to go is to try and print a unicode character before reading in the authors. |
|
Fundamentally both these problems occur because python is trying to read utf-8 encoded bytes and using the ascii codec instead. If we specify The |
|
This dockerfile will reproduce the unicode error during build, and also shows that this PR fixes it. |
|
@betatim you are right, ditching csv.reader is the Right Thing To Do. |
|
Ready for review |
|
@betatim, can you handle this review? |
|
LGTM. In a terminal "without unicode" python2 and 3 Thanks for this! Also if some of my earlier comments were a bit combative in their wording sorry, I was in a seriously foul mood that spilled over :-/ |
|
On Thu, Jul 13, 2017 at 08:51:31AM -0700, Tim Head wrote:
Also if some of my earlier comments were a bit combative in their wording sorry, I was in a seriously foul mood that spilled over :-/
thanks for the note! I didn't notice anything personally but I appreciate the
thought!
|
|
Merging this before I need to approve it for a third time :) |
This fixes #1735 for me (and I suspect #1565) in ubuntu:16.10 docker containers that were failing to build because of unicode in the author list.
I don't think the problem is lack of unicode support, it's that python3.5 is enforcing more strict handling of encodings.
make testDid it pass the tests?make clean diff-coverIf it introduces new functionality inscripts/is it tested?make format diff_pylint_report cppcheck doc pydocstyleIs it wellformatted?
additions are allowed without a major version increment. Changing file
formats also requires a major version number increment.
documented in
CHANGELOG.md? See keepachangelogfor more details.
changes were made?
tested for streaming IO?)