diff options
author | Wheeler Law <wheeler.law@outlook.com> | 2023-04-21 02:04:25 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-21 02:04:25 (GMT) |
commit | 5c00a6224d55f8818ef567b93f484b5429e2ae80 (patch) | |
tree | 9acd708383767c467730fc9d8677278b67495b1a /Lib/urllib | |
parent | 4898415df724380d4c8b0ec08e8cb92f126193c3 (diff) | |
download | cpython-5c00a6224d55f8818ef567b93f484b5429e2ae80.zip cpython-5c00a6224d55f8818ef567b93f484b5429e2ae80.tar.gz cpython-5c00a6224d55f8818ef567b93f484b5429e2ae80.tar.bz2 |
gh-99352: Respect `http.client.HTTPConnection.debuglevel` in `urllib.request.AbstractHTTPHandler` (#99353)
* bugfix: let the HTTP- and HTTPSHandlers respect the value of http.client.HTTPConnection.debuglevel
* add tests
* add news
* ReSTify NEWS and reword a bit.
* Address Review Comments.
* Use mock.patch.object instead of settting the module level value.
* Used test values to assert the debuglevel.
---------
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Senthil Kumaran <senthil@python.org>
Diffstat (limited to 'Lib/urllib')
-rw-r--r-- | Lib/urllib/request.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index 151034e..19e2e5b 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -1251,8 +1251,8 @@ class ProxyDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler): class AbstractHTTPHandler(BaseHandler): - def __init__(self, debuglevel=0): - self._debuglevel = debuglevel + def __init__(self, debuglevel=None): + self._debuglevel = debuglevel if debuglevel is not None else http.client.HTTPConnection.debuglevel def set_http_debuglevel(self, level): self._debuglevel = level @@ -1378,7 +1378,8 @@ if hasattr(http.client, 'HTTPSConnection'): class HTTPSHandler(AbstractHTTPHandler): - def __init__(self, debuglevel=0, context=None, check_hostname=None): + def __init__(self, debuglevel=None, context=None, check_hostname=None): + debuglevel = debuglevel if debuglevel is not None else http.client.HTTPSConnection.debuglevel AbstractHTTPHandler.__init__(self, debuglevel) if context is None: http_version = http.client.HTTPSConnection._http_vsn |