Skip to content
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

Closed
merwok opened this issue Mar 12, 2014 · 11 comments
Closed

distutils register command should print text, not bytes repr #65099

merwok opened this issue Mar 12, 2014 · 11 comments
Labels
easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@merwok
Copy link
Member

merwok commented Mar 12, 2014

BPO 20900
Nosy @merwok, @berkerpeksag
Files
  • issue20900.patch
  • 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:

    assignee = None
    closed_at = <Date 2016-06-10.20:04:09.471>
    created_at = <Date 2014-03-12.20:59:23.239>
    labels = ['easy', 'type-bug', 'library']
    title = 'distutils register command should print text, not bytes repr'
    updated_at = <Date 2016-06-10.20:04:09.470>
    user = 'https://github.com/merwok'

    bugs.python.org fields:

    activity = <Date 2016-06-10.20:04:09.470>
    actor = 'berker.peksag'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-06-10.20:04:09.471>
    closer = 'berker.peksag'
    components = ['Distutils']
    creation = <Date 2014-03-12.20:59:23.239>
    creator = 'eric.araujo'
    dependencies = []
    files = ['34436']
    hgrepos = []
    issue_num = 20900
    keywords = ['patch', 'easy']
    message_count = 11.0
    messages = ['213295', '213310', '213313', '213315', '213676', '213688', '213944', '214097', '268140', '268150', '268151']
    nosy_count = 5.0
    nosy_names = ['eric.araujo', 'Arfrever', 'python-dev', 'berker.peksag', 'ingrid']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue20900'
    versions = ['Python 3.5', 'Python 3.6']

    @merwok
    Copy link
    Member Author

    merwok commented Mar 12, 2014

    “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.

    @merwok merwok added stdlib Python modules in the Lib dir easy type-bug An unexpected behavior, bug, or error labels Mar 12, 2014
    @ingrid
    Copy link
    Mannequin

    ingrid mannequin commented Mar 12, 2014

    I haven't had to register a python package before. Is there a way to reproduce this without actually creating an entry in PyPI?

    @merwok
    Copy link
    Member Author

    merwok commented Mar 12, 2014

    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.

    @ingrid
    Copy link
    Mannequin

    ingrid mannequin commented Mar 12, 2014

    Ah, thanks! I'm looking at this now.

    @ingrid
    Copy link
    Mannequin

    ingrid mannequin commented Mar 15, 2014

    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.

    @merwok
    Copy link
    Member Author

    merwok commented Mar 15, 2014

    Thank you, the patch looks excellent. I’ll apply it in a day or two.

    @merwok merwok self-assigned this Mar 15, 2014
    @merwok
    Copy link
    Member Author

    merwok commented Mar 18, 2014

    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.

    @ingrid
    Copy link
    Mannequin

    ingrid mannequin commented Mar 19, 2014

    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.

    @berkerpeksag
    Copy link
    Member

    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:

    -        self.assertIn('xyzzy\n', results[-1])
    +        self.assertEqual(results[-1], 75 * '-' + '\nxyzzy\n' + 75 * '-')
    

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jun 10, 2016

    New changeset 02824cee7624 by Berker Peksag in branch '3.5':
    Issue bpo-20900: distutils register command now decodes HTTP responses correctly
    https://hg.python.org/cpython/rev/02824cee7624

    New changeset b0be24a2f16c by Berker Peksag in branch 'default':
    Issue bpo-20900: Merge from 3.5
    https://hg.python.org/cpython/rev/b0be24a2f16c

    @berkerpeksag
    Copy link
    Member

    Thanks for the patch ingrid!

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants