Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
adamtheturtle wants to merge1 commit intopython:main
base:main
Choose a base branch
Loading
fromadamtheturtle:patch-3

Conversation

adamtheturtle
Copy link
Contributor

@adamtheturtleadamtheturtle commentedJun 29, 2025
edited by github-actionsbot
Loading

…ter` have some positional-only arguments

importcsvwithopen("example.csv","w",newline='')ascsvfile:csv.writer(csvfile=csvfile)# TypeError:  expected at least 1 argument, got 0
importcsvcsv.reader(csvfile="a")# TypeError:  expected at least 1 argument, got 0

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

…sv.writer` have some positional-only arguments```pythonimport csvwith open("example.csv", "w", newline='') as csvfile:    csv.writer(csvfile=csvfile)  # TypeError:  expected at least 1 argument, got 0``````pythonimport csvcsv.reader(csvfile="a")  # TypeError:  expected at least 1 argument, got 0```
Copy link
Member

@ZeroIntensityZeroIntensity left a comment

Choose a reason for hiding this comment

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

LGTM.

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

cpython/Modules/_csv.c

Lines 1090 to 1100 inbd928a3

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

PyArg_UnpackTuple unpacks positional arguments, so I would have thought thatcsv.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 forcsvfile, so this is the correct description for the docs.

@picnixzpicnixz changed the titlegh-131885: Update csv.rst to describe thatcsv.reader and `csv.wri…gh-131885: update documented signatures forcsv.{writer,reader}Jun 29, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ZeroIntensityZeroIntensityZeroIntensity approved these changes

Assignees
No one assigned
Labels
awaiting mergedocsDocumentation in the Doc dirskip news
Projects
Status: Todo
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@adamtheturtle@ZeroIntensity

[8]ページ先頭

©2009-2025 Movatter.jp