This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: distutils register command should print text, not bytes repr
Type: behavior Stage: resolved
Components: Distutils Versions: Python 3.6, Python 3.5
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Arfrever, berker.peksag, eric.araujo, ingrid, python-dev
Priority: normal Keywords: easy, patch

Created on 2014-03-12 20:59 by eric.araujo, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
issue20900.patch ingrid, 2014-03-15 19:20 review
Messages (11)
msg213295 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2014-03-12 20:59
“python3 register --show-response“ will display something like "----------b'xxx'----------".  The HTTP response body should be decoded to text for display, instead of the repr of a bytes object.

Setting the “easy” keyword: thanks to unittest.mock, writing a test for this should not be hard, and with a test we can have the confidence to change the code.
msg213310 - (view) Author: (ingrid) * Date: 2014-03-12 22:26
I haven't had to register a python package before. Is there a way to reproduce this without actually creating an entry in PyPI?
msg213313 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2014-03-12 22:32
To get a better idea of the problem, you can run the code for real using as repository URL.  Then, unittest.mock provides a way to write a unit test that reproduces the bug without actually sending an HTTP request to any server.
msg213315 - (view) Author: (ingrid) * Date: 2014-03-12 22:39
Ah, thanks! I'm looking at this now.
msg213676 - (view) Author: (ingrid) * Date: 2014-03-15 19:20
Here is a patch. I made the register show-response format consistent with the upload show-response format and added tests for both. Please let me know if you have any feedback.
msg213688 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2014-03-15 22:19
Thank you, the patch looks excellent.  I’ll apply it in a day or two.
msg213944 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2014-03-18 05:47
Were you able to reproduce the bug before you changed the code?  I saw clean text when registering a release with success, and clean text too when trying to register a release for a project I was not owner of.
msg214097 - (view) Author: (ingrid) * Date: 2014-03-19 14:38
I'm not quite clear on what you mean, could you please post an example output? Initially the response was not showing up at all for me because the announce call in register was missing a log level, but when I used log.INFO, the response did print for me, and it did look something like "----------b'xxx'----------". 

On a side note, the announce function defined in seems to default to a log level 1, and messages with a log level of 1 do not seem to be printed to stdout regardless of what self.verbose is set to. I'm not sure if that is intentional or a bug, but I thought it was worth mentioning.
msg268140 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-06-10 18:35
issue20900.patch looks good to me. We are already testing output of "python upload --show-response" in Lib/distutils/tests/ so I removed test_show_reponse and tweaked test_upload to test the whole line:

    -        self.assertIn('xyzzy\n', results[-1])
    +        self.assertEqual(results[-1], 75 * '-' + '\nxyzzy\n' + 75 * '-')
msg268150 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-06-10 20:02
New changeset 02824cee7624 by Berker Peksag in branch '3.5':
Issue #20900: distutils register command now decodes HTTP responses correctly

New changeset b0be24a2f16c by Berker Peksag in branch 'default':
Issue #20900: Merge from 3.5
msg268151 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-06-10 20:04
Thanks for the patch ingrid!
Date User Action Args
2022-04-11 14:57:59adminsetgithub: 65099
2016-06-10 20:04:09berker.peksagsetstatus: open -> closed
messages: + msg268151

assignee: eric.araujo ->
resolution: fixed
stage: patch review -> resolved
2016-06-10 20:02:06python-devsetnosy: + python-dev
messages: + msg268150
2016-06-10 18:35:59berker.peksagsetnosy: + berker.peksag

messages: + msg268140
versions: + Python 3.5, Python 3.6, - Python 3.3, Python 3.4
2014-03-19 14:38:25ingridsetmessages: + msg214097
2014-03-18 05:47:20eric.araujosetmessages: + msg213944
2014-03-15 22:19:20eric.araujosetassignee: eric.araujo
messages: + msg213688
stage: needs patch -> patch review
2014-03-15 19:20:54ingridsetfiles: + issue20900.patch
keywords: + patch
messages: + msg213676
2014-03-12 22:39:47ingridsetmessages: + msg213315
2014-03-12 22:32:30eric.araujosetmessages: + msg213313
2014-03-12 22:26:58ingridsetnosy: + ingrid
messages: + msg213310
2014-03-12 21:04:26Arfreversetnosy: + Arfrever
2014-03-12 20:59:23eric.araujocreate