summaryrefslogtreecommitdiffstats
path: root/Lib/_pyio.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-03-26 17:10:29 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-03-26 17:10:29 (GMT)
commit59406a9d857f3060f21269266a14a778aebf9904 (patch)
tree30f4ece28889e310b59296a9dfa282bfe9a61ee8 /Lib/_pyio.py
parent1ef7c6bc85988092b7c4b964309b9e3f3a62afd9 (diff)
downloadcpython-59406a9d857f3060f21269266a14a778aebf9904.zip
cpython-59406a9d857f3060f21269266a14a778aebf9904.tar.gz
cpython-59406a9d857f3060f21269266a14a778aebf9904.tar.bz2
officially deprecated max_buffer_size
Diffstat (limited to 'Lib/_pyio.py')
-rw-r--r--Lib/_pyio.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index 5a7d2ca..654a69c 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -5,6 +5,7 @@ Python implementation of the io module.
import os
import abc
import codecs
+import warnings
# Import _thread instead of threading to reduce startup cost
try:
from _thread import allocate_lock as Lock
@@ -960,16 +961,20 @@ class BufferedWriter(_BufferedIOMixin):
The constructor creates a BufferedWriter for the given writeable raw
stream. If the buffer_size is not given, it defaults to
- DEFAULT_BUFFER_SIZE. If max_buffer_size is omitted, it defaults to
- twice the buffer size.
+ DEFAULT_BUFFER_SIZE.
"""
+ _warning_stack_offset = 2
+
def __init__(self, raw,
buffer_size=DEFAULT_BUFFER_SIZE, max_buffer_size=None):
raw._checkWritable()
_BufferedIOMixin.__init__(self, raw)
if buffer_size <= 0:
raise ValueError("invalid buffer size")
+ if max_buffer_size is not None:
+ warnings.warn("max_buffer_size is deprecated", DeprecationWarning,
+ self._warning_stack_offset)
self.buffer_size = buffer_size
self._write_buf = bytearray()
self._write_lock = Lock()
@@ -1055,8 +1060,7 @@ class BufferedRWPair(BufferedIOBase):
reader and writer are RawIOBase objects that are readable and
writeable respectively. If the buffer_size is omitted it defaults to
- DEFAULT_BUFFER_SIZE. The max_buffer_size (for the buffered writer)
- defaults to twice the buffer size.
+ DEFAULT_BUFFER_SIZE.
"""
# XXX The usefulness of this (compared to having two separate IO
@@ -1068,10 +1072,12 @@ class BufferedRWPair(BufferedIOBase):
The arguments are two RawIO instances.
"""
+ if max_buffer_size is not None:
+ warnings.warn("max_buffer_size is deprecated", DeprecationWarning, 2)
reader._checkReadable()
writer._checkWritable()
self.reader = BufferedReader(reader, buffer_size)
- self.writer = BufferedWriter(writer, buffer_size, max_buffer_size)
+ self.writer = BufferedWriter(writer, buffer_size)
def read(self, n=None):
if n is None:
@@ -1117,10 +1123,11 @@ class BufferedRandom(BufferedWriter, BufferedReader):
The constructor creates a reader and writer for a seekable stream,
raw, given in the first argument. If the buffer_size is omitted it
- defaults to DEFAULT_BUFFER_SIZE. The max_buffer_size (for the buffered
- writer) defaults to twice the buffer size.
+ defaults to DEFAULT_BUFFER_SIZE.
"""
+ _warning_stack_offset = 3
+
def __init__(self, raw,
buffer_size=DEFAULT_BUFFER_SIZE, max_buffer_size=None):
raw._checkSeekable()