-
Notifications
You must be signed in to change notification settings - Fork 137
Fix encoding issue between Python 2 and 3 #133
Conversation
codecov/__init__.py
Outdated
basestring | ||
except NameError: | ||
basestring = str | ||
if isinstance(reports, basestring): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost good.
For Python 2 you want if isinstance(reports, unicode)
(not (str, unicode)
),
for python 3 you want if isinstance(reports, str)
.
So the correct fix would be:
try:
unicode
except NameError:
# Must be Python 3, make an alias for str.
unicode = str
if isinstance(reports, unicode):
reports = reports.encode('utf-8')
However, Python 2 has bytes
being an alias for str
. So you can do:
if not isinstance(reports, bytes):
reports = reports.encode('utf-8')
@chfast I made the suggested change @stevepeak I also configured the tests to skip invalid CI providers. I had to skip a number of extra tests for AppVeyor to pass (including the one specifically for AppVeyor). There was another string encoding bug exposed in the tests that I fixed. let me know if there are any changes you'd like for this part of the patch, but I think having fewer tests run that consistently pass is better than having more tests run that consistently fail In addition, I updated the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The encoding part looks good. The tests/CI part is not up to me.
Regarding .gitignore, I suggest configuring a global gitignore file. |
I generated the gitignore using the following options on gitignore.io: linux,macos,python,pycharm+all It seem like a lot, but they're pretty well maintained and thorough. Would you rather I used a subset? |
@JrGoodle |
@blueyed I removed the .gitignore commit from this PR |
Addresses #130
Fix for issue introduced in #121
I tested this on my own project and it worked: https://circleci.com/gh/JrGoodle/clowder/154
It probably still needs to be tested with Python 2