FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-131885: update documented signatures for `csv.{writer,reader}` by adamtheturtle · Pull Request #136085 · python/cpython · GitHub

/ cpython Public

gh-131885: update documented signatures for csv.{writer,reader} - #136085

Merged
ZeroIntensity merged 1 commit into
python:mainfrom
adamtheturtle:patch-3
Jun 30, 2025
Merged

gh-131885: update documented signatures for csv.{writer,reader}#136085
ZeroIntensity merged 1 commit into
python:mainfrom
adamtheturtle:patch-3

Conversation

adamtheturtle commented Jun 29, 2025
edited by github-actions Bot
Loading

Copy link
Copy Markdown
Contributor

…ter` have some positional-only arguments

import csv

with open("example.csv", "w", newline='') as csvfile:
    csv.writer(csvfile=csvfile)  # TypeError:  expected at least 1 argument, got 0
import csv

csv.reader(csvfile="a")  # TypeError:  expected at least 1 argument, got 0

📚 Documentation preview 📚: https://cpython-previews--136085.org.readthedocs.build/

…ter` have some positional-only arguments


```python
import csv

with open("example.csv", "w", newline='') as csvfile:
    csv.writer(csvfile=csvfile)  # TypeError:  expected at least 1 argument, got 0
```

```python
import csv

csv.reader(csvfile="a")  # TypeError:  expected at least 1 argument, got 0
```

ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM.

Reading the source, I was a little confused at first:

cpython/Modules/_csv.c

Lines 1090 to 1100 in bd928a3

if (!PyArg_UnpackTuple(args, "reader", 1, 2, &iterator, &dialect)) {
Py_DECREF(self);
return NULL;
}
self->input_iter = PyObject_GetIter(iterator);
if (self->input_iter == NULL) {
Py_DECREF(self);
return NULL;
}
self->dialect = (DialectObj *)_call_dialect(module_state, dialect,
keyword_args);

PyArg_UnpackTuple unpacks positional arguments, so I would have thought that csv.writer(file, dialect="...") wouldn't work, but the catch is that _call_dialect checks if the dialect was non-NULL, and extracts it from the keywords if it is. But, there's nothing similar for csvfile, so this is the correct description for the docs.

picnixz changed the title gh-131885: Update csv.rst to describe that csv.reader and `csv.wri… gh-131885: update documented signatures for csv.{writer,reader} Jun 29, 2025
ZeroIntensity added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Jun 30, 2025
ZeroIntensity merged commit 75f4059 into python:main Jun 30, 2025

Copy link
Copy Markdown

Thanks @adamtheturtle for the PR, and @ZeroIntensity for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

github-project-automation Bot moved this from Todo to Done in Docs PRs Jun 30, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 30, 2025
…}` (pythonGH-136085)

(cherry picked from commit 75f4059)

Co-authored-by: Adam Dangoor <adamdangoor@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 30, 2025
…}` (pythonGH-136085)

(cherry picked from commit 75f4059)

Co-authored-by: Adam Dangoor <adamdangoor@gmail.com>

bedevere-app Bot commented Jun 30, 2025

Copy link
Copy Markdown

GH-136120 is a backport of this pull request to the 3.14 branch.

bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jun 30, 2025

bedevere-app Bot commented Jun 30, 2025

Copy link
Copy Markdown

GH-136121 is a backport of this pull request to the 3.13 branch.

bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jun 30, 2025
adamtheturtle deleted the patch-3 branch June 30, 2025 13:33

Copy link
Copy Markdown
Member

Thanks!

ZeroIntensity pushed a commit that referenced this pull request Jun 30, 2025
…r}` (GH-136085) (GH-136121)

gh-131885: Update documented signatures for `csv.{writer,reader}` (GH-136085)
(cherry picked from commit 75f4059)

Co-authored-by: Adam Dangoor <adamdangoor@gmail.com>
ZeroIntensity pushed a commit that referenced this pull request Jun 30, 2025
…r}` (GH-136085) (GH-136120)

gh-131885: Update documented signatures for `csv.{writer,reader}` (GH-136085)
(cherry picked from commit 75f4059)

Co-authored-by: Adam Dangoor <adamdangoor@gmail.com>
AndPuQing pushed a commit to AndPuQing/cpython that referenced this pull request Jul 11, 2025
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
picnixz pushed a commit to picnixz/cpython that referenced this pull request Jul 13, 2025
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL