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

debuglevel not honored in urllib #71079

Closed
yan12125 mannequin opened this issue Apr 30, 2016 · 5 comments
Closed

debuglevel not honored in urllib #71079

yan12125 mannequin opened this issue Apr 30, 2016 · 5 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@yan12125
Copy link
Mannequin

yan12125 mannequin commented Apr 30, 2016

BPO 26892
Nosy @orsenthil, @yan12125
Files
  • urllib_debuglevel.patch
  • urllib_debuglevel_test.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 = 'https://github.com/orsenthil'
    closed_at = <Date 2016-05-13.08:36:15.955>
    created_at = <Date 2016-04-30.10:04:43.881>
    labels = ['type-bug', 'library']
    title = 'debuglevel not honored in urllib'
    updated_at = <Date 2016-05-13.08:36:15.846>
    user = 'https://github.com/yan12125'

    bugs.python.org fields:

    activity = <Date 2016-05-13.08:36:15.846>
    actor = 'orsenthil'
    assignee = 'orsenthil'
    closed = True
    closed_date = <Date 2016-05-13.08:36:15.955>
    closer = 'orsenthil'
    components = ['Library (Lib)']
    creation = <Date 2016-04-30.10:04:43.881>
    creator = 'yan12125'
    dependencies = []
    files = ['42662', '42665']
    hgrepos = []
    issue_num = 26892
    keywords = ['patch']
    message_count = 5.0
    messages = ['264547', '264557', '264566', '265453', '265454']
    nosy_count = 3.0
    nosy_names = ['orsenthil', 'python-dev', 'yan12125']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue26892'
    versions = ['Python 3.5', 'Python 3.6']

    @yan12125
    Copy link
    Mannequin Author

    yan12125 mannequin commented Apr 30, 2016

    The following test program:

    import sys
    try:
        import urllib.request as urllib_request
    except:
        import urllib2 as urllib_request
    
    print(sys.version)
    
    handler = urllib_request.HTTPSHandler(debuglevel=1)
    opener = urllib_request.build_opener(handler)
    print(opener.open('https://httpbin.org/user-agent').read().decode('utf-8'))

    Works as expected in Python 2:
    $ python2 test_urllib_debuglevel.py
    2.7.11 (default, Mar 31 2016, 06:18:34)
    [GCC 5.3.0]
    send: 'GET /user-agent HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: httpbin.org\r\nConnection: close\r\nUser-Agent: Python-urllib/2.7\r\n\r\n'
    reply: 'HTTP/1.1 200 OK\r\n'
    header: Server: nginx
    header: Date: Sat, 30 Apr 2016 10:02:32 GMT
    header: Content-Type: application/json
    header: Content-Length: 40
    header: Connection: close
    header: Access-Control-Allow-Origin: *
    header: Access-Control-Allow-Credentials: true
    {
    "user-agent": "Python-urllib/2.7"
    }

    But the verbose output is unavailable in Python 3.x:
    $ ./python test_urllib_debuglevel.py
    3.6.0a0 (default:1ceb91974dc4, Apr 30 2016, 17:44:57)
    [GCC 5.3.0]
    {
    "user-agent": "Python-urllib/3.6"
    }

    Patch attached.

    @yan12125 yan12125 mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Apr 30, 2016
    @orsenthil
    Copy link
    Member

    Hi Chi Hsuan,

    The patch looks good to me. Additional tests for the coverage of this will be helpful too. Thanks!

    @yan12125
    Copy link
    Mannequin Author

    yan12125 mannequin commented Apr 30, 2016

    Patch for the test.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 13, 2016

    New changeset 63e23b2dedcc by Senthil Kumaran in branch '3.5':
    Issue bpo-26892: Honor debuglevel flag in urllib.request.HTTPHandler.
    https://hg.python.org/cpython/rev/63e23b2dedcc

    New changeset e0ec68d46464 by Senthil Kumaran in branch 'default':
    merge from 3.5
    https://hg.python.org/cpython/rev/e0ec68d46464

    @orsenthil
    Copy link
    Member

    Thank you for the patch, Chi Hsuan Yen.

    @orsenthil orsenthil self-assigned this May 13, 2016
    @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
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant