Issue 16915: mode of socket.makefile is more limited than documentation suggests (original) (raw)

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

Files
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 https://hg.python.org/cpython/rev/a7391c31ec4e New changeset bbfbde6ee9d0 by Berker Peksag in branch 'default': Issue #16915: Clarify that mode parameter of socket.makefile() does not accept https://hg.python.org/cpython/rev/bbfbde6ee9d0
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.
History
Date User Action Args
2022-04-11 14:57:40 admin set github: 61119
2016-02-18 15:40:39 berker.peksag set status: open -> closedassignee: docs@pythoncomponents: + Documentation, - Library (Lib)versions: + Python 3.5, Python 3.6, - Python 3.4nosy: + docs@python, berker.peksagmessages: + resolution: fixedstage: resolved
2016-02-18 15:35:28 python-dev set nosy: + python-devmessages: +
2013-01-13 14:02:18 Antoon.Pardon set messages: +
2013-01-11 12:06:54 federico.reghenzani set files: + t.patchversions: + Python 3.4, - Python 3.2nosy: + federico.reghenzanimessages: + keywords: + patch
2013-01-10 13:40:17 Antoon.Pardon create