Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_csv Reader and Writer types shouldn't be directly instantiable #104265

Closed
chgnrdv opened this issue May 7, 2023 · 0 comments · Fixed by #104266
Closed

_csv Reader and Writer types shouldn't be directly instantiable #104265

chgnrdv opened this issue May 7, 2023 · 0 comments · Fixed by #104266
Labels
type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@chgnrdv
Copy link
Contributor

chgnrdv commented May 7, 2023

The accepted way to create these objects is to use constructor functions _csv.reader() and _csv.writer() with appropriate arguments. Objects that are created through type constructors _csv.Reader and _csv.Writer turn out to be not properly initialized, and operations on them easily lead to crash:

>>> import _csv
>>> _csv.Writer().writerow([])
Segmentation fault (core dumped)
>>> import _csv
>>> list(_csv.Reader())
Segmentation fault (core dumped)

Although this is an internal detail, I'm sure that this should be fixed. I'll submit a PR shortly.
The crash appears on 3.10, 3.11 and current main.

Linked PRs

@chgnrdv chgnrdv added the type-crash A hard crash of the interpreter, possibly with a core dump label May 7, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 7, 2023
…ter` (pythonGH-104266)

(cherry picked from commit 06c2a48)

Co-authored-by: chgnrdv <52372310+chgnrdv@users.noreply.github.com>
kumaraditya303 pushed a commit that referenced this issue May 8, 2023
…iter` (GH-104266) (#104278)

gh-104265 Disallow instantiation of `_csv.Reader` and `_csv.Writer` (GH-104266)
(cherry picked from commit 06c2a48)

Co-authored-by: chgnrdv <52372310+chgnrdv@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant