gh-99352: Respect http.client.HTTPConnection.debuglevel in urllib.request.AbstractHTTPHandler #99353
Conversation
|
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
353519d to
518d0e2
Compare
|
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
ac4037b to
cc7f8d9
Compare
|
Who do I need to mention to get a review on this? |
gpshead
left a comment
There was a problem hiding this comment.
(be sure to pull first, i pushed an update to the news entry in the branch)
Lib/test/test_urllib2.py
Outdated
|
|
||
| def test_http_handler_debuglevel(self): | ||
| def test_http_handler_global_debuglevel(self): | ||
| http.client.HTTPConnection.debuglevel = 1 |
There was a problem hiding this comment.
use a with mock.patch.object(http.client.HTTPConnection, 'debuglevel, 1): style block to set this so that it is undone after the test. same below. I also suggest using a value other than 1 so that it is more obviously correlated with the specific test and not a default from elsewhere.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
…ent.HTTPConnection.debuglevel
* Use mock.patch.object instead of settting the module level value. * Used test values to assert the debuglevel.
031e8a9 to
ad096d4
Compare
orsenthil
left a comment
There was a problem hiding this comment.
LGTM. I have addressed the review comments against this change.
|
This appears to have caused failures on several buildbots. For example, https://buildbot.python.org/all/#/builders/15/builds/4336. |
|
@orsenthil, this is the one I was talking about. |
|
Oh. I see the issue now. Didn't realize we were disabling ssl in some builds. I will fix it. Sorry. |
|
Here we go - #103828 ; I can test against the failing buildbot before merging. |
…g https tests. (python#103828) pythongh-99352: Ensure HTTPSConnection is available before exercising https tests. This will fix the buildbot issue mentioned in python#99353
Fixes #99352.
Some proposed changes to allow the
AbstractHTTPHandleruse the value ofhttp.client.HTTPConnection.debuglevelif nodebuglevelis passed toAbstractHTTPHandler's constructor. This has to be done in the constructor body because argument default values are evaluated at function definition evaluation time andhttp.client.HTTPConnection.debuglevelcould be set afterurllib.requestis imported.With these proposed changes,
AbstractHTTPHandlerandHTTPSHandlernow respect both sources ofdebuglevel. If the value is not set in the constructor arguments, the constructor will source the value fromhttp.client.HTTPConnection.debuglevel.Using the global
http.client.HTTPConnection.debuglevel:Using the
debuglevelconstructor parameter:urllib.request.urlopen()no longer respects thehttp.client.HTTPConnection.debuglevelflag #99352