mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
remove usage of the deprecated max_buffer_size
This commit is contained in:
parent
36a30cefd7
commit
394ee00993
2 changed files with 14 additions and 14 deletions
13
Lib/_pyio.py
13
Lib/_pyio.py
|
@ -971,9 +971,6 @@ class BufferedWriter(_BufferedIOMixin):
|
|||
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 @@ class BufferedWriter(_BufferedIOMixin):
|
|||
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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue