diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2009-04-19 00:09:36 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2009-04-19 00:09:36 (GMT) |
commit | cf4c749680bc178f2afb469f8828790a7268d137 (patch) | |
tree | b82b665246bec0aa1ab1c099e72769ebc3ee70a7 /Lib/_pyio.py | |
parent | 561f36068f9a6ec70a49646a4ca78a411929a73c (diff) | |
download | cpython-cf4c749680bc178f2afb469f8828790a7268d137.zip cpython-cf4c749680bc178f2afb469f8828790a7268d137.tar.gz cpython-cf4c749680bc178f2afb469f8828790a7268d137.tar.bz2 |
Issue #5734: BufferedRWPair was poorly tested and had several glaring bugs.
Patch by Brian Quinlan.
Diffstat (limited to 'Lib/_pyio.py')
-rw-r--r-- | Lib/_pyio.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py index 0ef6822..fe020fd 100644 --- a/Lib/_pyio.py +++ b/Lib/_pyio.py @@ -839,7 +839,9 @@ class BufferedReader(_BufferedIOMixin): def __init__(self, raw, buffer_size=DEFAULT_BUFFER_SIZE): """Create a new buffered reader using the given readable raw IO object. """ - raw._checkReadable() + if not raw.readable(): + raise IOError('"raw" argument must be readable.') + _BufferedIOMixin.__init__(self, raw) if buffer_size <= 0: raise ValueError("invalid buffer size") @@ -970,7 +972,9 @@ class BufferedWriter(_BufferedIOMixin): def __init__(self, raw, buffer_size=DEFAULT_BUFFER_SIZE, max_buffer_size=None): - raw._checkWritable() + if not raw.writable(): + raise IOError('"raw" argument must be writable.') + _BufferedIOMixin.__init__(self, raw) if buffer_size <= 0: raise ValueError("invalid buffer size") @@ -1076,8 +1080,13 @@ class BufferedRWPair(BufferedIOBase): """ if max_buffer_size is not None: warnings.warn("max_buffer_size is deprecated", DeprecationWarning, 2) - reader._checkReadable() - writer._checkWritable() + + if not reader.readable(): + raise IOError('"reader" argument must be readable.') + + if not writer.writable(): + raise IOError('"writer" argument must be writable.') + self.reader = BufferedReader(reader, buffer_size) self.writer = BufferedWriter(writer, buffer_size) |