Skip to content

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
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
changed tests to use check_disallow_instantiation, separated tests
  • Loading branch information
chgnrdv committed May 7, 2023
commit aa34fae64b55982bb0abb8a306f4075fe17292c1
16 changes: 10 additions & 6 deletions Lib/test/test_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import gc
import pickle
from test import support
from test.support import warnings_helper
from test.support import warnings_helper, check_disallow_instantiation
from itertools import permutations
from textwrap import dedent
from collections import OrderedDict
Expand Down Expand Up @@ -1431,13 +1431,17 @@ def test_subclassable(self):
# issue 44089
class Foo(csv.Error): ...

def test_issue104265(self):
with self.assertRaisesRegex(TypeError, "cannot create '_csv.reader' instances"):
_csv.Reader()
with self.assertRaisesRegex(TypeError, "cannot create '_csv.writer' instances"):
_csv.Writer()
def test_reader_disallow_instantiation(self):
check_disallow_instantiation(self, _csv.Reader)

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

Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy