This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Bug in socket example
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.3, Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: bbrazil, georg.brandl, kiilerix, nicdumz, orsenthil, python-dev, sandro.tosi, thijs
Priority: normal Keywords: patch

Created on 2009-05-12 14:19 by kiilerix, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
socket.patch nicdumz, 2009-08-24 08:12 Documentation patch for socket and socketserver review
socket-sendall-doc-2.7.patch bbrazil, 2010-08-08 14:36 Updated patch for 2.7. review
socket-sendall-doc-py3k.patch bbrazil, 2010-08-08 14:36 Adapted patch for py3k. review
Messages (7)
msg87633 - (view) Author: Mads Kiilerich (kiilerix) * Date: 2009-05-12 14:19 says about socket.send:
"Applications are responsible for checking that all data has been sent;
if only some of the data was transmitted, the application needs to
attempt delivery of the remaining data."

And about socket.sendall:
"Unlike send(), this method continues to send data from string until
either all data has been sent or an error occurs."

However, the examples on the same page uses plain conn.send(data)
without checking anything. That is misleading.

A solution could be to use conn.sendall(data) instead.
msg91907 - (view) Author: Nicolas Dumazet (nicdumz) Date: 2009-08-24 08:12
I'm including a patch which replaces send by sendall in the examples in
both socket and socketserver.
msg113268 - (view) Author: Brian Brazil (bbrazil) * Date: 2010-08-08 14:36
I've updated this patch to apply cleanly to 2.7, and also adapted it to for py3k. I added a small tweak to the example description in socket.rst.

I've tested the instructions for both 2.7 and 3k and verified they still work as expected.
msg128198 - (view) Author: Sandro Tosi (sandro.tosi) * (Python committer) Date: 2011-02-08 23:06
Hi all,
I was looking at this issue and thought: ok the module documentation uses send() not correctly, so we should fix that; the fastest solution is using sendall().

But then searching fro some examples in the code on internet, I found that the python docs contain a "Socket Programming HOWTO" that uses send() the way it should be.

So, should we:

- replace send() with sendall() in socket module documentation (explaining it was done to not clutter examples) and
- add a reference to the socket programming howto to show a way to use send() correctly?

msg152935 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-02-09 09:44
New changeset aa6415d1e160 by Senthil Kumaran in branch '2.7':
Fix Issue #6005: Examples in the socket library documentation use sendall,
msg152936 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-02-09 09:56
New changeset 2aae44aa041a by Senthil Kumaran in branch '3.2':
Fix Issue #6005: Examples in the socket library documentation use sendall,

New changeset e9c3df45920e by Senthil Kumaran in branch 'default':
merged from 3.2
msg152937 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2012-02-09 09:57
Thanks for patches. This is fixed.
Date User Action Args
2022-04-11 14:56:48adminsetgithub: 50255
2012-02-09 09:57:25orsenthilsetstatus: open -> closed

nosy: + orsenthil
messages: + msg152937

resolution: fixed
stage: resolved
2012-02-09 09:56:31python-devsetmessages: + msg152936
2012-02-09 09:44:53python-devsetnosy: + python-dev
messages: + msg152935
2011-02-08 23:06:19sandro.tosisetnosy: + sandro.tosi
messages: + msg128198
2010-10-29 10:07:21adminsetassignee: georg.brandl -> docs@python
2010-08-08 14:36:59bbrazilsetfiles: + socket-sendall-doc-py3k.patch
2010-08-08 14:36:39bbrazilsetfiles: + socket-sendall-doc-2.7.patch
versions: + Python 2.7, Python 3.3, - Python 2.6
nosy: + bbrazil

messages: + msg113268
2009-09-23 17:49:53thijssetnosy: + thijs
2009-08-24 08:12:55nicdumzsetfiles: + socket.patch

nosy: + nicdumz
messages: + msg91907

keywords: + patch
2009-05-12 14:19:03kiilerixcreate