-
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
Conversation
@@ -64,7 +64,7 @@ def rehash(path, blocksize=1 << 20): | |||
return (digest, length) | |||
|
|||
|
|||
def open_for_csv(name, mode): | |||
def open_for_csv(name, mode, encoding='utf8'): |
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 to tests/data/packages/
, then add a test similar to test_basic_install_from_wheel
in tests/functional/test_install_wheel.py
. Do that without your changes, run your new test with something like tox -- -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 valid open
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!
src/pip/_internal/wheel.py
Outdated
@@ -71,7 +71,7 @@ def open_for_csv(name, mode, encoding='utf8'): | |||
else: | |||
nl = {'newline': ''} | |||
bin = '' | |||
return open(name, mode + bin, **nl) | |||
return open(name, mode + bin, encoding=encoding, **nl) |
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.
Again, you really need to add a test: what about Python 2 support (the file is opened in binary mode)?
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.
As noted by @benoit-pierre
Hello! I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the |
I think that merge went wrong @julienmalard. :/ |
Oops... Thanks and sorry, |
This should be a simple rebase. You'll need to fix a merge conflict, for updating the type signature for There's instructions for this at https://pip.pypa.io/en/latest/development/contributing/#updating-your-branch, but if they're not super helpful, please feel free to ping me and I'll be happy to provide step-by-step guidance for the rebase to you. :) |
Hello,
Would it be possible to provide step-by-step guidance given where I am right now (i.e., with a merge already gone wrong?)
Thanks a lot!
…________________________________
દ્વારા: Pradyun Gedam <[email protected]>
મોકલ્યું: 03 જાન્યુઆરી 2019 02:27:28
પ્રતિ: pypa/pip
Cc: Julien Malard; Mention
વિષય: Re: [pypa/pip] Default to utf-8 for csv opening. (#5712)
This should be a simple rebase. You'll need to fix a merge conflict, for updating the type signature for open_for_csv to include the encoding parameter type.
There's instructions for this at https://pip.pypa.io/en/latest/development/contributing/#updating-your-branch, but if they're not super helpful, please feel free to ping me and I'll be happy to provide step-by-step guidance for the rebase to you. :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#5712 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AKMb68pD906SgRS6BR61ZH4TDBcFnM0Fks5u_bDggaJpZM4WB4XV>.
|
Sure! This is a simple rebase, you have to fix one merge conflict and ignore one patch manually.
Feel free to ping me in case something is not clear. |
This solves problems when installing packages with unicode module or package names.
Hello, |
From this PR, it is unclear what you are trying to fix. As asked in pypa/setuptools#1399 it would be helpful to produce a minimal example failing in your case. Your
which does not seem to fail on a csv. |
Thanks for the quick response! Will investigate and get back to you soon. |
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
# type: (str, Text, str)
Since it has been some time without progress here I will close this, but anyone should feel free to re-raise this as a PR or issue if the information above can be provided. Thanks! |
Hello, Any chance this could be reopened? I am trying to fix this PR and it would be helpful to see if the tests now pass. Thanks, |
GitHub won't allow reopening at this time. The hover message on the disabled "Reopen and comment" button states: "The master branch was force-pushed or recreated." I would try creating a new branch off of your current commit, fetch and overwrite the master from the main pypa/pip repository, and then rebase your new branch on your local master. It would look something like (assuming you have the main pypa/pip repo set as a remote called
Then you can push |
Done, thank you! I continued it in a new pull request (#7138). |
This solves problems when installing packages with unicode module or package names on Windows and resolves this issue originally reported to setuptools:
pypa/setuptools#1399