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

Skip to content

Commit babc688

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.
1 parent 56dee1e commit babc688

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
@@ -74,12 +74,14 @@
7474
import collections
7575
from urllib.parse import urlsplit
7676

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

8486
HTTP_PORT = 80
8587
HTTPS_PORT = 443

Lib/test/test_httplib.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,22 @@ def __init__(self, *pos, **kw):
708708
self.assertTrue(response.closed)
709709
self.assertTrue(conn.sock.file_closed)
710710

711+
711712
class OfflineTest(TestCase):
713+
def test_all(self):
714+
# Documented objects defined in the module should be in __all__
715+
expected = {"responses"} # White-list documented dict() object
716+
# HTTPMessage, parse_headers(), and the HTTP status code constants are
717+
# intentionally omitted for simplicity
718+
blacklist = {"HTTPMessage", "parse_headers"}
719+
for name in dir(client):
720+
if name in blacklist:
721+
continue
722+
module_object = getattr(client, name)
723+
if getattr(module_object, "__module__", None) == "http.client":
724+
expected.add(name)
725+
self.assertCountEqual(client.__all__, expected)
726+
712727
def test_responses(self):
713728
self.assertEqual(client.responses[client.NOT_FOUND], "Not Found")
714729

0 commit comments

Comments
 (0)