[New-bugs-announce] [issue26892] debuglevel not honored in urllib

Chi Hsuan Yen report at bugs.python.org
Sat Apr 30 06:04:43 EDT 2016


New submission from Chi Hsuan Yen:

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.

----------
components: Library (Lib)
files: urllib_debuglevel.patch
keywords: patch
messages: 264547
nosy: Chi Hsuan Yen
priority: normal
severity: normal
status: open
title: debuglevel not honored in urllib
type: behavior
versions: Python 3.6
Added file: http://bugs.python.org/file42662/urllib_debuglevel.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26892>
_______________________________________


More information about the New-bugs-announce mailing list