-
-
Notifications
You must be signed in to change notification settings - Fork 34.8k
[2.7] bpo-32304: Fix distutils upload for tar files ending with b'\r' (GH-5264) #5331
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,6 +128,32 @@ def test_upload(self): | |
| auth = self.last_open.req.headers['Authorization'] | ||
| self.assertNotIn('\n', auth) | ||
|
|
||
| # bpo-32304: archives whose last byte was b'\r' were corrupted due to | ||
| # normalization intended for Mac OS 9. | ||
| def test_upload_correct_cr(self): | ||
| # content that ends with \r should not be modified. | ||
| tmp = self.mkdtemp() | ||
| path = os.path.join(tmp, 'xxx') | ||
| self.write_file(path, content='yy\r') | ||
| command, pyversion, filename = 'xxx', '2.6', path | ||
| dist_files = [(command, pyversion, filename)] | ||
| self.write_file(self.rc, PYPIRC_LONG_PASSWORD) | ||
|
|
||
| # other fields that ended with \r used to be modified, now are | ||
| # preserved. | ||
| pkg_dir, dist = self.create_dist( | ||
| dist_files=dist_files, | ||
| description='long description\r' | ||
| ) | ||
| cmd = upload(dist) | ||
| cmd.ensure_finalized() | ||
| cmd.run() | ||
|
|
||
| headers = dict(self.last_open.req.headers) | ||
| self.assertEqual(headers['Content-length'], '2170') | ||
| self.assertIn(b'long description\r', self.last_open.req.data) | ||
|
Member
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. This test would not catch a regression, i.e. fail if the request data contains
Contributor
Author
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. The size check earlier would signal the error, but I've added a new line to make it explicit.
Member
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. Thanks! |
||
| self.assertNotIn(b'long description\r\n', self.last_open.req.data) | ||
|
|
||
| def test_upload_fails(self): | ||
| self.next_msg = "Not Found" | ||
| self.next_code = 404 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| distutils' upload command no longer corrupts tar files ending with a CR byte, | ||
| and no longer tries to convert CR to CRLF in any of the upload text fields. |
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.
This is the test failure: https://travis-ci.org/python/cpython/jobs/333550360#L2640-L2647
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.
Yeah, I see what's going on - the cmd.show_response isn't the same in this version. There are some other differences in the test I'll smooth out shortly.