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: mode of socket.makefile is more limited than documentation suggests
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.6, Python 3.5
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Antoon.Pardon, berker.peksag, docs@python, federico.reghenzani, python-dev
Priority: normal Keywords: patch

Created on 2013-01-10 13:40 by Antoon.Pardon, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
t.patch federico.reghenzani, 2013-01-11 12:06 review
Messages (5)
msg179543 - (view) Author: Antoon Pardon (Antoon.Pardon) Date: 2013-01-10 13:40
The documentation of socket.makefile states that its arguments are interpreted the same way as by the built-in open() function. However the mode argument of socket.makefile only allows 'r', 'w' and 'b'.

That some options are not allowed seems perfectly normal, like there being no use of an 'x' option but the documentation should probably reflect that.

But I don't see why the 't' should cause trouble. If people can open a file explicitly in text mode, I don't see why it wouldn't be possible to explicitly ask for text mode in socket.makefile
msg179673 - (view) Author: Federico Reghenzani (federico.reghenzani) * Date: 2013-01-11 12:06
I think that 't' option can be added to conform with open() built-in function. The other options I don't think it's possible to use with sockets.

Adding the 't' doesn't change the makefile() behavior. I added also a clarification in documentation.
msg179873 - (view) Author: Antoon Pardon (Antoon.Pardon) Date: 2013-01-13 14:02
I think one could argue for allowing mode "r+" instead of "wb". Because "w" suggest truncation, which doesn't make sense on sockets either.

But in the end I agree that allowing 'r', 'w', 'b' and 't' is probably the best compromise available.
msg260462 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-02-18 15:35
New changeset a7391c31ec4e by Berker Peksag in branch '3.5':
Issue #16915: Clarify that mode parameter of socket.makefile() does not accept

New changeset bbfbde6ee9d0 by Berker Peksag in branch 'default':
Issue #16915: Clarify that mode parameter of socket.makefile() does not accept
msg260463 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-02-18 15:40
Thanks for the report and for the patch. I would prefer to keep the code simple so I just applied documentation changes with a minor tweak.
Date User Action Args
2022-04-11 14:57:40adminsetgithub: 61119
2016-02-18 15:40:39berker.peksagsetstatus: open -> closed

assignee: docs@python
components: + Documentation, - Library (Lib)
versions: + Python 3.5, Python 3.6, - Python 3.4
nosy: + docs@python, berker.peksag

messages: + msg260463
resolution: fixed
stage: resolved
2016-02-18 15:35:28python-devsetnosy: + python-dev
messages: + msg260462
2013-01-13 14:02:18Antoon.Pardonsetmessages: + msg179873
2013-01-11 12:06:54federico.reghenzanisetfiles: + t.patch
versions: + Python 3.4, - Python 3.2
nosy: + federico.reghenzani

messages: + msg179673

keywords: + patch
2013-01-10 13:40:17Antoon.Pardoncreate