[Python-checkins] r70201 - in python/branches/py3k: Doc/library/io.rst Lib/_pyio.py
benjamin.peterson
python-checkins at python.org
Thu Mar 5 23:33:59 CET 2009
Author: benjamin.peterson
Date: Thu Mar 5 23:33:59 2009
New Revision: 70201
Log:
remove usage of the deprecated max_buffer_size
Modified:
python/branches/py3k/Doc/library/io.rst
python/branches/py3k/Lib/_pyio.py
Modified: python/branches/py3k/Doc/library/io.rst
==============================================================================
--- python/branches/py3k/Doc/library/io.rst (original)
+++ python/branches/py3k/Doc/library/io.rst Thu Mar 5 23:33:59 2009
@@ -505,8 +505,9 @@
The constructor creates a :class:`BufferedWriter` for the given writeable
*raw* stream. If the *buffer_size* is not given, it defaults to
- :data:`DEFAULT_BUFFER_SIZE`. If *max_buffer_size* is omitted, it defaults to
- twice the buffer size.
+ :data:`DEFAULT_BUFFER_SIZE`.
+
+ *max_buffer_size* is unused and deprecated.
:class:`BufferedWriter` provides or overrides these methods in addition to
those from :class:`BufferedIOBase` and :class:`IOBase`:
@@ -532,8 +533,9 @@
*reader* and *writer* are :class:`RawIOBase` objects that are readable and
writeable respectively. If the *buffer_size* is omitted it defaults to
- :data:`DEFAULT_BUFFER_SIZE`. The *max_buffer_size* (for the buffered writer)
- defaults to twice the buffer size.
+ :data:`DEFAULT_BUFFER_SIZE`.
+
+ *max_buffer_size* is unused and deprecated.
:class:`BufferedRWPair` implements all of :class:`BufferedIOBase`\'s methods.
@@ -545,8 +547,9 @@
The constructor creates a reader and writer for a seekable raw stream, given
in the first argument. If the *buffer_size* is omitted it defaults to
- :data:`DEFAULT_BUFFER_SIZE`. The *max_buffer_size* (for the buffered writer)
- defaults to twice the buffer size.
+ :data:`DEFAULT_BUFFER_SIZE`.
+
+ *max_buffer_size* is unused and deprecated.
:class:`BufferedRandom` is capable of anything :class:`BufferedReader` or
:class:`BufferedWriter` can do.
Modified: python/branches/py3k/Lib/_pyio.py
==============================================================================
--- python/branches/py3k/Lib/_pyio.py (original)
+++ python/branches/py3k/Lib/_pyio.py Thu Mar 5 23:33:59 2009
@@ -971,9 +971,6 @@
if buffer_size <= 0:
raise ValueError("invalid buffer size")
self.buffer_size = buffer_size
- self.max_buffer_size = (2*buffer_size
- if max_buffer_size is None
- else max_buffer_size)
self._write_buf = bytearray()
self._write_lock = Lock()
@@ -1000,12 +997,12 @@
try:
self._flush_unlocked()
except BlockingIOError as e:
- if len(self._write_buf) > self.max_buffer_size:
- # We've hit max_buffer_size. We have to accept a
- # partial write and cut back our buffer.
- overage = len(self._write_buf) - self.max_buffer_size
+ if len(self._write_buf) > self.buffer_size:
+ # We've hit the buffer_size. We have to accept a partial
+ # write and cut back our buffer.
+ overage = len(self._write_buf) - self.buffer_size
written -= overage
- self._write_buf = self._write_buf[:self.max_buffer_size]
+ self._write_buf = self._write_buf[:self.buffer_size]
raise BlockingIOError(e.errno, e.strerror, written)
return written
More information about the Python-checkins
mailing list