bpo-11594: Ensure line-endings are respected when using 2to3#6483
bpo-11594: Ensure line-endings are respected when using 2to3#6483ambv merged 7 commits intopython:masterfrom
Conversation
|
Looks good to me! |
|
Can you add a news file also? |
|
@jaraco Done 👍 |
| return fp.read() | ||
|
|
||
| old_contents = read_file() | ||
| rt = self.rt(fixers=fixers) |
There was a problem hiding this comment.
Would be nicer if you extracted lines 210-221 to a separate function that both check_file_refactoring() and refactor_file() would reuse. Now there's copypasta.
| print "Like bad Windows newlines?" | ||
| print "hi" | ||
| print "Like bad Windows newlines?" |
There was a problem hiding this comment.
Wow, that's hilarious. We've had a \r\n file but something along the way wiped the newlines O_O
|
@ambv Thank you for taking the time for reviewing this patch. I didn't refactor it exactly the way you told me to because I felt it was too much "extracting the similarities just for the sake of keeping the code DRY". Instead, I extracted certain functionality, "initializing the test file" and "reading the test file", into separate functions |
|
Much better. Thanks! |
…H-6483) (cherry picked from commit c127a86) Co-authored-by: Aaron Ang <[email protected]>
|
GH-6515 is a backport of this pull request to the 3.7 branch. |
|
Sorry, @aaronang and @ambv, I could not cleanly backport this to |
(cherry picked from commit c127a86) Co-authored-by: Aaron Ang <[email protected]>
|
@aaronang Did this not make the 3.7.0 release? I'm seeing my line endings being changed from CRLF to CRCRLF (yikes!) on Windows. Or perhaps that's a different issue? |
|
According to the news file, this PR was included in 3.7.0b4. Sounds like you may have identified a new issue. |
|
@jaraco Good to know. All tests passed on my Windows PC. Could you add a test case for CRLF files on Windows? I don't know if the automated tests are run against Windows but I could run it manually if needed. |
|
@aaronang I think I see where things went wrong. In adding I think the patch also needs something like: |
|
I am sorry for the late reply. I am looking into it now. |
|
@blah238 Could you apply this patch to the master: And run: For me this doesn't fail locally. |
|
@aaronang to be clear, when the test didn't fail, did you run it on Windows? I didn't run the test suite, but I did verify the behavior on a Windows machine. |
|
@jaraco I am sorry for being unclear. I don't have a Windows machine so I couldn't test whether the test with the patch (that you proposed) fails or not on Windows. |
|
@jaraco I am sorry for asking this but could you test out the patch that you proposed to see if it fixes the problem? I am not really capable of fixing the problem because I don't have a Windows machine available. I am a bit embarrassed for asking this 😓 |
|
I’m pretty sure this is the right fix. I’ll submit a PR with just the test update to demonstrate the failure then apply the fix. |
|
@jaraco I really wanted to help out but don't have a Windows machine available. Thanks a lot! |
|
@blah238 - The fix should come in 3.7.1, but feel free to grab the latest refactor.py from the Python 3.7 branch and replace it in your installation. |
https://bugs.python.org/issue11594