@@ -1415,6 +1415,16 @@ PyTypeObject PyBufferedReader_Type = {
14151415};
14161416
14171417
1418+
1419+ static int
1420+ complain_about_max_buffer_size (void )
1421+ {
1422+ if (PyErr_WarnEx (PyExc_DeprecationWarning ,
1423+ "max_buffer_size is deprecated" , 1 ) < 0 )
1424+ return 0 ;
1425+ return 1 ;
1426+ }
1427+
14181428/*
14191429 * class BufferedWriter
14201430 */
@@ -1439,7 +1449,7 @@ BufferedWriter_init(BufferedObject *self, PyObject *args, PyObject *kwds)
14391449 /* TODO: properly deprecate max_buffer_size */
14401450 char * kwlist [] = {"raw" , "buffer_size" , "max_buffer_size" , NULL };
14411451 Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE ;
1442- Py_ssize_t max_buffer_size = -1 ;
1452+ Py_ssize_t max_buffer_size = -234 ;
14431453 PyObject * raw ;
14441454
14451455 self -> ok = 0 ;
@@ -1449,6 +1459,9 @@ BufferedWriter_init(BufferedObject *self, PyObject *args, PyObject *kwds)
14491459 return -1 ;
14501460 }
14511461
1462+ if (max_buffer_size != -234 && !complain_about_max_buffer_size ())
1463+ return -1 ;
1464+
14521465 if (_PyIOBase_checkWritable (raw , Py_True ) == NULL )
14531466 return -1 ;
14541467
@@ -1767,8 +1780,7 @@ PyDoc_STRVAR(BufferedRWPair_doc,
17671780 "\n"
17681781 "reader and writer are RawIOBase objects that are readable and\n"
17691782 "writeable respectively. If the buffer_size is omitted it defaults to\n"
1770- "DEFAULT_BUFFER_SIZE. The max_buffer_size (for the buffered writer)\n"
1771- "defaults to twice the buffer size.\n"
1783+ "DEFAULT_BUFFER_SIZE.\n"
17721784 );
17731785
17741786/* XXX The usefulness of this (compared to having two separate IO objects) is
@@ -1789,13 +1801,16 @@ BufferedRWPair_init(BufferedRWPairObject *self, PyObject *args,
17891801{
17901802 PyObject * reader , * writer ;
17911803 Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE ;
1792- Py_ssize_t max_buffer_size = -1 ;
1804+ Py_ssize_t max_buffer_size = -234 ;
17931805
17941806 if (!PyArg_ParseTuple (args , "OO|nn:BufferedRWPair" , & reader , & writer ,
17951807 & buffer_size , & max_buffer_size )) {
17961808 return -1 ;
17971809 }
17981810
1811+ if (max_buffer_size != -234 && !complain_about_max_buffer_size ())
1812+ return -1 ;
1813+
17991814 if (_PyIOBase_checkReadable (reader , Py_True ) == NULL )
18001815 return -1 ;
18011816 if (_PyIOBase_checkWritable (writer , Py_True ) == NULL )
@@ -1812,7 +1827,7 @@ BufferedRWPair_init(BufferedRWPairObject *self, PyObject *args,
18121827 if (self -> reader == NULL )
18131828 return -1 ;
18141829
1815- args = Py_BuildValue ("(nn )" , buffer_size , max_buffer_size );
1830+ args = Py_BuildValue ("(n )" , buffer_size );
18161831 if (args == NULL ) {
18171832 Py_CLEAR (self -> reader );
18181833 return -1 ;
@@ -2016,7 +2031,7 @@ BufferedRandom_init(BufferedObject *self, PyObject *args, PyObject *kwds)
20162031{
20172032 char * kwlist [] = {"raw" , "buffer_size" , "max_buffer_size" , NULL };
20182033 Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE ;
2019- Py_ssize_t max_buffer_size = -1 ;
2034+ Py_ssize_t max_buffer_size = -234 ;
20202035 PyObject * raw ;
20212036
20222037 self -> ok = 0 ;
@@ -2026,6 +2041,9 @@ BufferedRandom_init(BufferedObject *self, PyObject *args, PyObject *kwds)
20262041 return -1 ;
20272042 }
20282043
2044+ if (max_buffer_size != -234 && !complain_about_max_buffer_size ())
2045+ return -1 ;
2046+
20292047 if (_PyIOBase_checkSeekable (raw , Py_True ) == NULL )
20302048 return -1 ;
20312049 if (_PyIOBase_checkReadable (raw , Py_True ) == NULL )
0 commit comments