Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 394ee00

Browse files
committed
remove usage of the deprecated max_buffer_size
1 parent 36a30ce commit 394ee00

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

Doc/library/io.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,9 @@ Buffered Streams
505505

506506
The constructor creates a :class:`BufferedWriter` for the given writeable
507507
*raw* stream. If the *buffer_size* is not given, it defaults to
508-
:data:`DEFAULT_BUFFER_SIZE`. If *max_buffer_size* is omitted, it defaults to
509-
twice the buffer size.
508+
:data:`DEFAULT_BUFFER_SIZE`.
509+
510+
*max_buffer_size* is unused and deprecated.
510511

511512
:class:`BufferedWriter` provides or overrides these methods in addition to
512513
those from :class:`BufferedIOBase` and :class:`IOBase`:
@@ -532,8 +533,9 @@ Buffered Streams
532533

533534
*reader* and *writer* are :class:`RawIOBase` objects that are readable and
534535
writeable respectively. If the *buffer_size* is omitted it defaults to
535-
:data:`DEFAULT_BUFFER_SIZE`. The *max_buffer_size* (for the buffered writer)
536-
defaults to twice the buffer size.
536+
:data:`DEFAULT_BUFFER_SIZE`.
537+
538+
*max_buffer_size* is unused and deprecated.
537539

538540
:class:`BufferedRWPair` implements all of :class:`BufferedIOBase`\'s methods.
539541

@@ -545,8 +547,9 @@ Buffered Streams
545547

546548
The constructor creates a reader and writer for a seekable raw stream, given
547549
in the first argument. If the *buffer_size* is omitted it defaults to
548-
:data:`DEFAULT_BUFFER_SIZE`. The *max_buffer_size* (for the buffered writer)
549-
defaults to twice the buffer size.
550+
:data:`DEFAULT_BUFFER_SIZE`.
551+
552+
*max_buffer_size* is unused and deprecated.
550553

551554
:class:`BufferedRandom` is capable of anything :class:`BufferedReader` or
552555
:class:`BufferedWriter` can do.

Lib/_pyio.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -971,9 +971,6 @@ def __init__(self, raw,
971971
if buffer_size <= 0:
972972
raise ValueError("invalid buffer size")
973973
self.buffer_size = buffer_size
974-
self.max_buffer_size = (2*buffer_size
975-
if max_buffer_size is None
976-
else max_buffer_size)
977974
self._write_buf = bytearray()
978975
self._write_lock = Lock()
979976

@@ -1000,12 +997,12 @@ def write(self, b):
1000997
try:
1001998
self._flush_unlocked()
1002999
except BlockingIOError as e:
1003-
if len(self._write_buf) > self.max_buffer_size:
1004-
# We've hit max_buffer_size. We have to accept a
1005-
# partial write and cut back our buffer.
1006-
overage = len(self._write_buf) - self.max_buffer_size
1000+
if len(self._write_buf) > self.buffer_size:
1001+
# We've hit the buffer_size. We have to accept a partial
1002+
# write and cut back our buffer.
1003+
overage = len(self._write_buf) - self.buffer_size
10071004
written -= overage
1008-
self._write_buf = self._write_buf[:self.max_buffer_size]
1005+
self._write_buf = self._write_buf[:self.buffer_size]
10091006
raise BlockingIOError(e.errno, e.strerror, written)
10101007
return written
10111008

0 commit comments

Comments
 (0)