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.

classification
Title: Python2 documentation of the open() built-in function
Type: behavior Stage: resolved
Components: Documentation Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, eli.bendersky, ezio.melotti, jannkruse, python-dev, r.david.murray
Priority: low Keywords:

Created on 2011-07-26 21:20 by jannkruse, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (4)
msg141183 - (view) Author: Jann Eike Kruse (jannkruse) Date: 2011-07-26 21:20
The documentation page 

http://docs.python.org/release/2.6.6/library/functions.html?highlight=open#open

describes the  open()  built-in function as

  open(filename[, mode[, bufsize]])

but the Python interpreter complains:

  Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) 
  [GCC 4.4.5] on linux2 
  Type "help", "copyright", "credits" or "license" for more information.
  >>> 
  >>> 
  >>> file_descriptor = open(filename='/spam')
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
  TypeError: Required argument 'name' (pos 1) not found
  >>> 
  >>> 
  >>> file_descriptor = open(name='/spam', bufsize=-1)
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
  TypeError: 'bufsize' is an invalid keyword argument for this function
  >>> 
  >>> 
  >>> file_descriptor = open(name='/spam', buffering=-1)
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
  IOError: [Errno 2] No such file or directory: '/spam'
  >>> _
  

So the documentation page should read

  open(name[, mode[, buffering]])
       ----          ---------

instead, note 'name' not 'filename' and 'buffering' not 'bufsize'.

Maybe it's relevant, because Debian/stable still ships with
Python 2.6.6 and I guess the Python 2.7.x documentation has 
the same bug.

The """docstring""" does already reflect that correctly.


PS:
This is my first bug report. I hope I did this right. 
Mercy, please! ;)
msg141188 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-07-26 21:58
The docs are correct in Python3.

The docs for Python2 are not *wrong*, since they indicate only positional parameters and if you use positional parameters it works as documented. (I'm surprised that using keyword arguments works, but I haven't looked at the code.)  Fixing the names in the 2.7 docs would still be helpful (2.6 docs don't get updated any more).
msg141207 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-07-27 05:49
New changeset 5da7924c4775 by Ezio Melotti in branch '2.7':
#12642: fix args names in open() doc.
http://hg.python.org/cpython/rev/5da7924c4775
msg141208 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-07-27 05:50
Fixed, thanks for the report!
History
Date User Action Args
2022-04-11 14:57:20adminsetgithub: 56851
2011-07-27 05:50:30ezio.melottisetstatus: open -> closed

nosy: + ezio.melotti
messages: + msg141208

resolution: fixed
stage: needs patch -> resolved
2011-07-27 05:49:03python-devsetnosy: + python-dev
messages: + msg141207
2011-07-27 03:31:27eli.benderskysetnosy: + eli.bendersky
2011-07-26 21:58:48r.david.murraysetpriority: normal -> low

type: behavior

title: 2.6.6 documentation of the open() built-in function -> Python2 documentation of the open() built-in function
nosy: + r.david.murray
versions: + Python 2.7, - Python 2.6
messages: + msg141188
stage: needs patch
2011-07-26 21:20:19jannkrusecreate