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: Wrong argument name for csv.DictReader in documentation
Type: Stage: resolved
Components: Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Mariatta, cowlinator, josh.r, matrixise, r.david.murray, serhiy.storchaka
Priority: normal Keywords: needs review

Created on 2018-02-07 01:51 by cowlinator, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 5575 merged matrixise, 2018-02-07 06:27
Messages (12)
msg311759 - (view) Author: cowlinator (cowlinator) Date: 2018-02-07 01:51
The documentation for the csv.DictReader constructor (and presumably csv.DictWriter also) has the wrong name written for the first argument.  This prevents the argument from being called by name.

>>> file = open("file.txt", 'a')
>>> csv.DictReader(csvfile=file)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __init__() takes at least 2 arguments (1 given)
>>> csv.DictReader(f=file)
<csv.DictReader instance at 0x04D97A08>
>>> # how could i have known it was named 'f'?

Please change the documentation.
msg311761 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2018-02-07 02:49
In the python3 docs it is given as 'f'.  In the python2 docs, it is not.  I suppose a doc backport was missed.
msg311763 - (view) Author: Josh Rosenberg (josh.r) * (Python triager) Date: 2018-02-07 04:10
Side-note: You say "how could i have known it was named 'f'?"

>>> help(csv.DictReader)
class DictReader
 |  Methods defined here:
 |
 |  __init__(self, f, fieldnames=None, restkey=None, restval=None, dialect='excel', *args, **kwds)
... rest of class help ...

Not saying the docs shouldn't be fixed, but the name is correctly given in the __init__ prototype (being implemented in Python, the names are always available to help() introspection, barring really specific cases of manual parsing of **kwargs). Just a general tip for the future.
msg311765 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2018-02-07 06:33
I just fixed the documentation, but I think we should change the name of the first parameter in master for 3.8. Maybe for 3.7, because we have to fix the docs. 

@david, what is your opinion?

I am going to propose a PR for the naming of the first argument
msg311768 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-02-07 07:04
See issue16026 for the fix in 3.x.
msg311769 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2018-02-07 07:34
Hi @Serhiy

I try to use the cherry-picking method for the patch from 3.6 but without success, I preferred to reuse my initial commit and remove the News.d entry.
msg311787 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2018-02-07 12:06
Stéphane: I don't understand your question about changing the name of the parameter.  As far as I can see the only thing to do here is backport the doc fix to 2.7.
msg311788 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2018-02-07 12:26
Hi David, 

At the final, I didn't propose my PR with the renaming. because PyPy and CPython use f as the first parameter of these classes.

If @Serhiy does the review of my PR, we can close this issue.
msg311794 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2018-02-07 16:05
New changeset 672fd7d8162f76aff8423fa5c7bfd2b1e91faf57 by Mariatta (Stéphane Wirtel) in branch '2.7':
bpo-32784: Wrong argument name for csv.DictReader in documentation (GH-5575)
https://github.com/python/cpython/commit/672fd7d8162f76aff8423fa5c7bfd2b1e91faf57
msg311795 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2018-02-07 16:07
Thanks everyone!
msg311859 - (view) Author: cowlinator (cowlinator) Date: 2018-02-09 01:28
Hi, thanks for the quick action on this!

The documentation is still wrong for 3.5 .  I had selected 3.5 for the affected versions, but I guess it got removed?
msg311860 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2018-02-09 01:32
3.5 is for security fixes only now. We don't do documentation or regular bug fixes there anymore.
History
Date User Action Args
2022-04-11 14:58:57adminsetgithub: 76965
2018-02-09 01:32:40Mariattasetmessages: + msg311860
versions: - Python 3.5
2018-02-09 01:28:41cowlinatorsetmessages: + msg311859
versions: + Python 3.5
2018-02-07 16:07:00Mariattasetstatus: open -> closed
resolution: fixed
messages: + msg311795

stage: patch review -> resolved
2018-02-07 16:05:42Mariattasetnosy: + Mariatta
messages: + msg311794
2018-02-07 12:26:34matrixisesetmessages: + msg311788
2018-02-07 12:06:56r.david.murraysetmessages: + msg311787
2018-02-07 07:34:07matrixisesetmessages: + msg311769
2018-02-07 07:04:29serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg311768
2018-02-07 06:33:04matrixisesetkeywords: + needs review, - patch
nosy: + matrixise
messages: + msg311765

2018-02-07 06:27:44matrixisesetkeywords: + patch
stage: patch review
pull_requests: + pull_request5393
2018-02-07 04:10:34josh.rsetnosy: + josh.r
messages: + msg311763
2018-02-07 02:49:05r.david.murraysetnosy: + r.david.murray

messages: + msg311761
versions: - Python 3.5
2018-02-07 01:51:05cowlinatorcreate