[pypy-svn] pypy default: Expose errors property on W_TextIOWrapper.

alex_gaynor commits-noreply at bitbucket.org
Mon Jan 31 03:52:51 CET 2011


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r41483:43b90b3858c2
Date: 2011-01-30 21:29 -0500
http://bitbucket.org/pypy/pypy/changeset/43b90b3858c2/

Log:	Expose errors property on W_TextIOWrapper.

diff --git a/pypy/module/_io/interp_textio.py b/pypy/module/_io/interp_textio.py
--- a/pypy/module/_io/interp_textio.py
+++ b/pypy/module/_io/interp_textio.py
@@ -311,6 +311,7 @@
 
         if space.is_w(w_errors, space.w_None):
             w_errors = space.wrap("strict")
+        self.w_errors = w_errors
 
         if space.is_w(w_newline, space.w_None):
             newline = None
@@ -983,6 +984,7 @@
     name = GetSetProperty(W_TextIOWrapper.name_get_w),
     buffer = interp_attrproperty_w("w_buffer", cls=W_TextIOWrapper),
     closed = GetSetProperty(W_TextIOWrapper.closed_get_w),
+    errors = interp_attrproperty_w("w_errors", cls=W_TextIOWrapper),
     _CHUNK_SIZE = GetSetProperty(
         W_TextIOWrapper.chunk_size_get_w, W_TextIOWrapper.chunk_size_set_w
     ),

diff --git a/pypy/module/_io/test/test_io.py b/pypy/module/_io/test/test_io.py
--- a/pypy/module/_io/test/test_io.py
+++ b/pypy/module/_io/test/test_io.py
@@ -267,3 +267,11 @@
         with _io.open(self.tmpfile, "r+") as f:
             res = f.read()
             assert res == ""
+
+    def test_errors_property(self):
+        import _io
+
+        with _io.open(self.tmpfile, "w") as f:
+            assert f.errors == "strict"
+        with _io.open(self.tmpfile, "w", errors="replace") as f:
+            assert f.errors == "replace"


More information about the Pypy-commit mailing list