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
distutils register command should print text, not bytes repr #65099
Comments
“python3 setup.py 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. |
I haven't had to register a python package before. Is there a way to reproduce this without actually creating an entry in PyPI? |
To get a better idea of the problem, you can run the code for real using https://testpypi.python.org/pypi 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. |
Ah, thanks! I'm looking at this now. |
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. |
Thank you, the patch looks excellent. I’ll apply it in a day or two. |
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. |
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 cmd.py 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. |
bpo-20900.patch looks good to me. We are already testing output of "python -setup.py upload --show-response" in Lib/distutils/tests/test_upload.py so I removed test_show_reponse and tweaked test_upload to test the whole line:
|
New changeset 02824cee7624 by Berker Peksag in branch '3.5': New changeset b0be24a2f16c by Berker Peksag in branch 'default': |
Thanks for the patch ingrid! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: