[Python-checkins] cpython (3.4): Issue #23439: Add missing entries to http.client.__all__.
berker.peksag
python-checkins at python.org
Fri Feb 20 08:44:11 CET 2015
https://hg.python.org/cpython/rev/21b31f5438ae
changeset: 94694:21b31f5438ae
branch: 3.4
parent: 94692:428cc8aa0843
user: Berker Peksag <berker.peksag at gmail.com>
date: Fri Feb 20 09:39:38 2015 +0200
summary:
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.
files:
Doc/library/http.client.rst | 6 ++++++
Lib/http/client.py | 4 +++-
Lib/test/test_httplib.py | 15 +++++++++++++++
3 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/Doc/library/http.client.rst b/Doc/library/http.client.rst
--- a/Doc/library/http.client.rst
+++ b/Doc/library/http.client.rst
@@ -169,6 +169,12 @@
status code that we don't understand.
+.. exception:: LineTooLong
+
+ A subclass of :exc:`HTTPException`. Raised if an excessively long line
+ is received in the HTTP protocol from the server.
+
+
The constants defined in this module are:
.. data:: HTTP_PORT
diff --git a/Lib/http/client.py b/Lib/http/client.py
--- a/Lib/http/client.py
+++ b/Lib/http/client.py
@@ -74,12 +74,14 @@
import collections
from urllib.parse import urlsplit
+# HTTPMessage, parse_headers(), and the HTTP status code constants are
+# intentionally omitted for simplicity
__all__ = ["HTTPResponse", "HTTPConnection",
"HTTPException", "NotConnected", "UnknownProtocol",
"UnknownTransferEncoding", "UnimplementedFileMode",
"IncompleteRead", "InvalidURL", "ImproperConnectionState",
"CannotSendRequest", "CannotSendHeader", "ResponseNotReady",
- "BadStatusLine", "error", "responses"]
+ "BadStatusLine", "LineTooLong", "error", "responses"]
HTTP_PORT = 80
HTTPS_PORT = 443
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py
--- a/Lib/test/test_httplib.py
+++ b/Lib/test/test_httplib.py
@@ -708,7 +708,22 @@
self.assertTrue(response.closed)
self.assertTrue(conn.sock.file_closed)
+
class OfflineTest(TestCase):
+ def test_all(self):
+ # Documented objects defined in the module should be in __all__
+ expected = {"responses"} # White-list documented dict() object
+ # HTTPMessage, parse_headers(), and the HTTP status code constants are
+ # intentionally omitted for simplicity
+ blacklist = {"HTTPMessage", "parse_headers"}
+ for name in dir(client):
+ if name in blacklist:
+ continue
+ module_object = getattr(client, name)
+ if getattr(module_object, "__module__", None) == "http.client":
+ expected.add(name)
+ self.assertCountEqual(client.__all__, expected)
+
def test_responses(self):
self.assertEqual(client.responses[client.NOT_FOUND], "Not Found")
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list