diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-12-21 21:20:59 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-12-21 21:20:59 (GMT) |
commit | 7f8f41808b82b5e4812bc2e2d484a6fc8f02295c (patch) | |
tree | d04b34c9a8897cfdc8fce780f002b15b97502e12 /Lib/_pyio.py | |
parent | cfee0e83ebd8826dbdc89035d15e1ea90a577fa2 (diff) | |
download | cpython-7f8f41808b82b5e4812bc2e2d484a6fc8f02295c.zip cpython-7f8f41808b82b5e4812bc2e2d484a6fc8f02295c.tar.gz cpython-7f8f41808b82b5e4812bc2e2d484a6fc8f02295c.tar.bz2 |
Issue #10750: The `raw` attribute of buffered IO objects is now read-only.
Diffstat (limited to 'Lib/_pyio.py')
-rw-r--r-- | Lib/_pyio.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py index 87c833c..2a6e7a8 100644 --- a/Lib/_pyio.py +++ b/Lib/_pyio.py @@ -676,7 +676,7 @@ class _BufferedIOMixin(BufferedIOBase): """ def __init__(self, raw): - self.raw = raw + self._raw = raw ### Positioning ### @@ -720,8 +720,8 @@ class _BufferedIOMixin(BufferedIOBase): if self.raw is None: raise ValueError("raw stream already detached") self.flush() - raw = self.raw - self.raw = None + raw = self._raw + self._raw = None return raw ### Inquiries ### @@ -736,6 +736,10 @@ class _BufferedIOMixin(BufferedIOBase): return self.raw.writable() @property + def raw(self): + return self._raw + + @property def closed(self): return self.raw.closed @@ -1465,7 +1469,7 @@ class TextIOWrapper(TextIOBase): if not isinstance(errors, str): raise ValueError("invalid errors: %r" % errors) - self.buffer = buffer + self._buffer = buffer self._line_buffering = line_buffering self._encoding = encoding self._errors = errors @@ -1520,6 +1524,10 @@ class TextIOWrapper(TextIOBase): def line_buffering(self): return self._line_buffering + @property + def buffer(self): + return self._buffer + def seekable(self): return self._seekable @@ -1734,8 +1742,8 @@ class TextIOWrapper(TextIOBase): if self.buffer is None: raise ValueError("buffer is already detached") self.flush() - buffer = self.buffer - self.buffer = None + buffer = self._buffer + self._buffer = None return buffer def seek(self, cookie, whence=0): |