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

Skip to content

Commit 8e28679

Browse files
committed
Issue #23439: Add missing entries to http.client.__all__.
Also, document the LineTooLong exception since it can be raised by the members of public API (e.g. http.client.HTTPResponse). Patch by Martin Panter.
2 parents 868a5a7 + babc688 commit 8e28679

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

Doc/library/http.client.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ The following exceptions are raised as appropriate:
169169
status code that we don't understand.
170170

171171

172+
.. exception:: LineTooLong
173+
174+
A subclass of :exc:`HTTPException`. Raised if an excessively long line
175+
is received in the HTTP protocol from the server.
176+
177+
172178
The constants defined in this module are:
173179

174180
.. data:: HTTP_PORT

Lib/http/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,14 @@
7575
import collections
7676
from urllib.parse import urlsplit
7777

78+
# HTTPMessage, parse_headers(), and the HTTP status code constants are
79+
# intentionally omitted for simplicity
7880
__all__ = ["HTTPResponse", "HTTPConnection",
7981
"HTTPException", "NotConnected", "UnknownProtocol",
8082
"UnknownTransferEncoding", "UnimplementedFileMode",
8183
"IncompleteRead", "InvalidURL", "ImproperConnectionState",
8284
"CannotSendRequest", "CannotSendHeader", "ResponseNotReady",
83-
"BadStatusLine", "error", "responses"]
85+
"BadStatusLine", "LineTooLong", "error", "responses"]
8486

8587
HTTP_PORT = 80
8688
HTTPS_PORT = 443

Lib/test/test_httplib.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,22 @@ def readline(self, limit):
920920
self.remainder = b"".join(data)
921921
raise
922922

923+
923924
class OfflineTest(TestCase):
925+
def test_all(self):
926+
# Documented objects defined in the module should be in __all__
927+
expected = {"responses"} # White-list documented dict() object
928+
# HTTPMessage, parse_headers(), and the HTTP status code constants are
929+
# intentionally omitted for simplicity
930+
blacklist = {"HTTPMessage", "parse_headers"}
931+
for name in dir(client):
932+
if name in blacklist:
933+
continue
934+
module_object = getattr(client, name)
935+
if getattr(module_object, "__module__", None) == "http.client":
936+
expected.add(name)
937+
self.assertCountEqual(client.__all__, expected)
938+
924939
def test_responses(self):
925940
self.assertEqual(client.responses[client.NOT_FOUND], "Not Found")
926941

0 commit comments

Comments
 (0)