summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-06-06 18:02:12 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-06-06 18:02:12 (GMT)
commit0926ad1f05f06233a7595b9f837cc3c5ee5fe46d (patch)
tree7bc723cd73aaaa3557b9da6d4e6ecc979aaa57ec /Lib
parent3bbbf18a38ad2af62a090692acb6f1299baf9aba (diff)
downloadcpython-0926ad1f05f06233a7595b9f837cc3c5ee5fe46d.zip
cpython-0926ad1f05f06233a7595b9f837cc3c5ee5fe46d.tar.gz
cpython-0926ad1f05f06233a7595b9f837cc3c5ee5fe46d.tar.bz2
give the C implementation of TextIOWrapper the errors property #6217
Diffstat (limited to 'Lib')
-rw-r--r--Lib/_pyio.py11
-rw-r--r--Lib/test/test_io.py6
-rw-r--r--Lib/test/test_memoryio.py6
3 files changed, 20 insertions, 3 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index c1cdf43..bbf65bc 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -1286,6 +1286,13 @@ class TextIOBase(IOBase):
"""
return None
+ @property
+ def errors(self):
+ """Error setting of the decoder or encoder.
+
+ Subclasses should override."""
+ return None
+
io.TextIOBase.register(TextIOBase)
@@ -1933,6 +1940,10 @@ class StringIO(TextIOWrapper):
return object.__repr__(self)
@property
+ def errors(self):
+ return None
+
+ @property
def encoding(self):
return None
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 1337b7c..4405d99 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -2024,6 +2024,12 @@ class TextIOWrapperTest(unittest.TestCase):
with self.open(filename, 'rb') as f:
self.assertEquals(f.read(), 'bbbzzz'.encode(charset))
+ def test_errors_property(self):
+ with self.open(support.TESTFN, "w") as f:
+ self.assertEqual(f.errors, "strict")
+ with self.open(support.TESTFN, "w", errors="replace") as f:
+ self.assertEqual(f.errors, "replace")
+
class CTextIOWrapperTest(TextIOWrapperTest):
diff --git a/Lib/test/test_memoryio.py b/Lib/test/test_memoryio.py
index d94d9dd..0d044e9 100644
--- a/Lib/test/test_memoryio.py
+++ b/Lib/test/test_memoryio.py
@@ -459,9 +459,9 @@ class PyStringIOTest(MemoryTestMixin, MemorySeekTestMixin, unittest.TestCase):
# These are just dummy values but we nevertheless check them for fear
# of unexpected breakage.
- self.assertTrue(memio.encoding is None)
- self.assertEqual(memio.errors, "strict")
- self.assertEqual(memio.line_buffering, False)
+ self.assertIsNone(memio.encoding)
+ self.assertIsNone(memio.errors)
+ self.assertFalse(memio.line_buffering)
def test_newline_none(self):
# newline=None