-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default to utf-8 for csv opening. #5712
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix unicode filename issues on Windows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
import compileall | ||
import csv | ||
import hashlib | ||
import io | ||
import logging | ||
import os.path | ||
import re | ||
|
@@ -80,15 +81,15 @@ def rehash(path, blocksize=1 << 20): | |
return (digest, str(length)) # type: ignore | ||
|
||
|
||
def open_for_csv(name, mode): | ||
def open_for_csv(name, mode, encoding='utf8'): | ||
# type: (str, Text) -> IO | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if sys.version_info[0] < 3: | ||
nl = {} # type: Dict[str, Any] | ||
bin = 'b' | ||
else: | ||
nl = {'newline': ''} # type: Dict[str, Any] | ||
bin = '' | ||
return open(name, mode + bin, **nl) | ||
return io.open(name, mode + bin, **nl) | ||
|
||
|
||
def replace_python_tag(wheelname, new_tag): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from setuptools import setup, find_packages | ||
|
||
setup( | ||
name="வணக்கம்", | ||
packages=find_packages(), | ||
version='0.0.1', | ||
description="A sample unicode project", | ||
) |
Empty file.
Empty file.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
encoding
is not used... You really need to add a test for this.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.
Thanks! I had copied over the changes from my local copy of pip.
Would you have any guidance as to where/how to add a test for this case? The error occurs when installing wheels which have unicode module names.
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.
Create a minimal project that triggers the bug, add its sources to
tests/data/src/
and a resulting wheel totests/data/packages/
, then add a test similar totest_basic_install_from_wheel
intests/functional/test_install_wheel.py
. Do that without your changes, run your new test with something liketox -- -k test_install_wheel_with_unicode_filenames
, and make sure you can reproduce the failure, then fix the test by adding your changes. Check Python 2 still work, and push.You also need to add a news entry: https://pip.pypa.io/en/stable/development/#adding-a-news-entry
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.
And
encoding
is not a validopen
keyword argument in Python 2.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.
Thanks for the guidance! I will work on this and get back to you.
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.
Hello,
I just made some changes for open and added a test. Will see how the pull request works now (I am not working from a Windows machine at the moment).
Could you help with the wheel test please? I could not figure out how to point a new wheel test to the new unicode_file example in the data folder.
Also, mypy seems to be failing but I am not sure why.
Thanks!
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.
Hello,
Any help please?
Many thanks for your support!