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

Appearance settings

gh-104265 Disallow instantiation of _csv.Reader and _csv.Writer #104266

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

Merged
merged 13 commits into from
May 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
reverted Py_TPFLAGS_BASETYPE flag deletion, removed corresponding tests
  • Loading branch information
chgnrdv committed May 7, 2023
commit 6c45ff87210c6e26633e24f9a45b11adf0b4bd71
8 changes: 0 additions & 8 deletions 8 Lib/test/test_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -1437,13 +1437,5 @@ def test_reader_disallow_instantiation(self):
def test_writer_disallow_instantiation(self):
check_disallow_instantiation(self, _csv.Writer)

def test_reader_not_basetype(self):
with self.assertRaisesRegex(TypeError, "type '_csv.reader' is not an acceptable base type"):
class Foo(_csv.Reader): pass

def test_writer_not_basetype(self):
with self.assertRaisesRegex(TypeError, "type '_csv.writer' is not an acceptable base type"):
class Foo(_csv.Writer): pass

if __name__ == '__main__':
unittest.main()
4 changes: 2 additions & 2 deletions 4 Modules/_csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ static PyType_Slot Reader_Type_slots[] = {
PyType_Spec Reader_Type_spec = {
.name = "_csv.reader",
.basicsize = sizeof(ReaderObj),
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION),
.slots = Reader_Type_slots
};
Expand Down Expand Up @@ -1430,7 +1430,7 @@ static PyType_Slot Writer_Type_slots[] = {
PyType_Spec Writer_Type_spec = {
.name = "_csv.writer",
.basicsize = sizeof(WriterObj),
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION),
.slots = Writer_Type_slots,
};
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.