From b12771ab3048bb61b3dc09fd21198613f43fa030 Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Mon, 23 Apr 2012 23:50:07 +0800 Subject: [PATCH 1/4] 3.2 - Fix for Issue13684 - httplib tunnel infinite loop --- Lib/http/client.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Lib/http/client.py b/Lib/http/client.py index 745b999942b..6828f146a7c 100644 --- a/Lib/http/client.py +++ b/Lib/http/client.py @@ -715,6 +715,9 @@ class HTTPConnection: line = response.fp.readline(_MAXLINE + 1) if len(line) > _MAXLINE: raise LineTooLong("header line") + if not line: + # for sites which EOF without sending a trailer + break if line == b'\r\n': break From 88ec6209cfd0c691df596f681144e1e7c5206dd9 Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Mon, 23 Apr 2012 23:53:16 +0800 Subject: [PATCH 2/4] news for issue13684 --- Misc/NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Misc/NEWS b/Misc/NEWS index cc243be2e15..fddcb7c352c 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -50,6 +50,9 @@ Core and Builtins Library ------- +- Issue #13684: Fix httplib tunnel issue of infinite loops for certain sites + which send EOF without trailing \r\n. + - Issue #14629: Raise SyntaxError in tokenizer.detect_encoding if the first two lines have non-UTF-8 characters without an encoding declaration. From c43125a05cc2f942ae8ba372b1dbe2e2e75d446a Mon Sep 17 00:00:00 2001 From: R David Murray Date: Mon, 23 Apr 2012 13:23:57 -0400 Subject: [PATCH 3/4] #14638: pydoc now treats non-str __name__ as None instead of raising Original patch by Peter Otten. --- Lib/pydoc.py | 3 ++- Lib/test/test_pydoc.py | 11 +++++++++++ Misc/NEWS | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Lib/pydoc.py b/Lib/pydoc.py index 89fd09b5567..37616fb3edd 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -1525,7 +1525,8 @@ def resolve(thing, forceload=0): raise ImportError('no Python documentation found for %r' % thing) return object, thing else: - return thing, getattr(thing, '__name__', None) + name = getattr(thing, '__name__', None) + return thing, name if isinstance(name, str) else None def render_doc(thing, title='Python Library Documentation: %s', forceload=0, renderer=None): diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py index 65b0ab540ee..c5a8e983568 100644 --- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -282,6 +282,17 @@ class PydocDocTest(unittest.TestCase): result, doc_loc = get_pydoc_text(xml.etree) self.assertEqual(doc_loc, "", "MODULE DOCS incorrectly includes a link") + def test_non_str_name(self): + # issue14638 + # Treat illegal (non-str) name like no name + class A: + __name__ = 42 + class B: + pass + adoc = pydoc.render_doc(A()) + bdoc = pydoc.render_doc(B()) + self.assertEqual(adoc.replace("A", "B"), bdoc) + def test_not_here(self): missing_module = "test.i_am_not_here" result = str(run_pydoc(missing_module), 'ascii') diff --git a/Misc/NEWS b/Misc/NEWS index fddcb7c352c..6feb4dac3c0 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -50,6 +50,9 @@ Core and Builtins Library ------- +- Issue #14638: pydoc now treats non-string __name__ values as if they + were missing, instead of raising an error. + - Issue #13684: Fix httplib tunnel issue of infinite loops for certain sites which send EOF without trailing \r\n. From cfdba61c3c51cff0e63e5cf8997a1eeb5d5f1a5a Mon Sep 17 00:00:00 2001 From: Sandro Tosi Date: Mon, 23 Apr 2012 19:45:07 +0200 Subject: [PATCH 4/4] Issue #14641: minor fixes to sockets Howto; patch by Dionysios Kalofonos --- Doc/howto/sockets.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/howto/sockets.rst b/Doc/howto/sockets.rst index a4ae9c0b1b7..279bb3ef5e7 100644 --- a/Doc/howto/sockets.rst +++ b/Doc/howto/sockets.rst @@ -153,7 +153,7 @@ I'm not going to talk about it here, except to warn you that you need to use there, you may wait forever for the reply, because the request may still be in your output buffer. -Now we come the major stumbling block of sockets - ``send`` and ``recv`` operate +Now we come to the major stumbling block of sockets - ``send`` and ``recv`` operate on the network buffers. They do not necessarily handle all the bytes you hand them (or expect from them), because their major focus is handling the network buffers. In general, they return when the associated network buffers have been @@ -164,7 +164,7 @@ been completely dealt with. When a ``recv`` returns 0 bytes, it means the other side has closed (or is in the process of closing) the connection. You will not receive any more data on this connection. Ever. You may be able to send data successfully; I'll talk -about that some on the next page. +more about this later. A protocol like HTTP uses a socket for only one transfer. The client sends a request, then reads a reply. That's it. The socket is discarded. This means that