Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 052ddb0

Browse files
committed
#17460: Remove the strict argument of HTTPConnection and removing the
DeprecationWarning being issued from 3.2 onwards.
1 parent aad1d87 commit 052ddb0

3 files changed

Lines changed: 14 additions & 32 deletions

File tree

Doc/library/http.client.rst

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ HTTPS protocols. It is normally not used directly --- the module
2727
The module provides the following classes:
2828

2929

30-
.. class:: HTTPConnection(host, port=None[, strict][, timeout], \
30+
.. class:: HTTPConnection(host, port=None[, timeout], \
3131
source_address=None)
3232

3333
An :class:`HTTPConnection` instance represents one transaction with an HTTP
@@ -51,13 +51,9 @@ The module provides the following classes:
5151
.. versionchanged:: 3.2
5252
*source_address* was added.
5353

54-
.. versionchanged:: 3.2
55-
The *strict* parameter is deprecated. HTTP 0.9-style "Simple Responses"
56-
are not supported anymore.
57-
5854

5955
.. class:: HTTPSConnection(host, port=None, key_file=None, \
60-
cert_file=None[, strict][, timeout], \
56+
cert_file=None[, timeout], \
6157
source_address=None, *, context=None, \
6258
check_hostname=None)
6359
@@ -89,20 +85,12 @@ The module provides the following classes:
8985
This class now supports HTTPS virtual hosts if possible (that is,
9086
if :data:`ssl.HAS_SNI` is true).
9187

92-
.. versionchanged:: 3.2
93-
The *strict* parameter is deprecated. HTTP 0.9-style "Simple Responses"
94-
are not supported anymore.
95-
9688

97-
.. class:: HTTPResponse(sock, debuglevel=0[, strict], method=None, url=None)
89+
.. class:: HTTPResponse(sock, debuglevel=0, method=None, url=None)
9890

9991
Class whose instances are returned upon successful connection. Not
10092
instantiated directly by user.
10193

102-
.. versionchanged:: 3.2
103-
The *strict* parameter is deprecated. HTTP 0.9-style "Simple Responses"
104-
are not supported anymore.
105-
10694

10795
The following exceptions are raised as appropriate:
10896

Lib/http/client.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,6 @@ def parse_headers(fp, _class=HTTPMessage):
267267
return email.parser.Parser(_class=_class).parsestr(hstring)
268268

269269

270-
_strict_sentinel = object()
271-
272270
class HTTPResponse(io.RawIOBase):
273271

274272
# See RFC 2616 sec 19.6 and RFC 1945 sec 6 for details.
@@ -278,7 +276,7 @@ class HTTPResponse(io.RawIOBase):
278276
# text following RFC 2047. The basic status line parsing only
279277
# accepts iso-8859-1.
280278

281-
def __init__(self, sock, debuglevel=0, strict=_strict_sentinel, method=None, url=None):
279+
def __init__(self, sock, debuglevel=0, method=None, url=None):
282280
# If the response includes a content-length header, we need to
283281
# make sure that the client doesn't read more than the
284282
# specified number of bytes. If it does, it will block until
@@ -288,10 +286,6 @@ def __init__(self, sock, debuglevel=0, strict=_strict_sentinel, method=None, url
288286
# clients unless they know what they are doing.
289287
self.fp = sock.makefile("rb")
290288
self.debuglevel = debuglevel
291-
if strict is not _strict_sentinel:
292-
warnings.warn("the 'strict' argument isn't supported anymore; "
293-
"http.client now always assumes HTTP/1.x compliant servers.",
294-
DeprecationWarning, 2)
295289
self._method = method
296290

297291
# The HTTPResponse object is returned via urllib. The clients
@@ -737,12 +731,8 @@ class HTTPConnection:
737731
# as a reasonable estimate of the maximum MSS.
738732
mss = 16384
739733

740-
def __init__(self, host, port=None, strict=_strict_sentinel,
741-
timeout=socket._GLOBAL_DEFAULT_TIMEOUT, source_address=None):
742-
if strict is not _strict_sentinel:
743-
warnings.warn("the 'strict' argument isn't supported anymore; "
744-
"http.client now always assumes HTTP/1.x compliant servers.",
745-
DeprecationWarning, 2)
734+
def __init__(self, host, port=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
735+
source_address=None):
746736
self.timeout = timeout
747737
self.source_address = source_address
748738
self.sock = None
@@ -1177,9 +1167,10 @@ class HTTPSConnection(HTTPConnection):
11771167
# XXX Should key_file and cert_file be deprecated in favour of context?
11781168

11791169
def __init__(self, host, port=None, key_file=None, cert_file=None,
1180-
strict=_strict_sentinel, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
1181-
source_address=None, *, context=None, check_hostname=None):
1182-
super(HTTPSConnection, self).__init__(host, port, strict, timeout,
1170+
timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
1171+
source_address=None, *, context=None,
1172+
check_hostname=None):
1173+
super(HTTPSConnection, self).__init__(host, port, timeout,
11831174
source_address)
11841175
self.key_file = key_file
11851176
self.cert_file = cert_file

Misc/NEWS

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,10 @@ Core and Builtins
287287
Library
288288
-------
289289

290-
Issue #16880: Do not assume _imp.load_dynamic() is defined in the imp module.
290+
- Issue #17460: Remove the strict argument of HTTPConnection and removing the
291+
DeprecationWarning being issued from 3.2 onwards.
292+
293+
- Issue #16880: Do not assume _imp.load_dynamic() is defined in the imp module.
291294

292295
- Issue #16389: Fixed a performance regression relative to Python 3.1 in the
293296
caching of compiled regular expressions.

0 commit comments

Comments
 (0)