bpo-39734: Deprecate the readinto() fallback path in _pickle.c
This commit is contained in:
parent
c49016e67c
commit
2b54cce96c
|
@ -3404,7 +3404,10 @@ class AbstractPicklerUnpicklerObjectTests(unittest.TestCase):
|
|||
def test_multiple_unpicklings_minimal(self):
|
||||
# File-like object that doesn't support peek() and readinto()
|
||||
# (bpo-39681)
|
||||
self._check_multiple_unpicklings(MinimalIO, seekable=False)
|
||||
import warnings
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", DeprecationWarning)
|
||||
self._check_multiple_unpicklings(MinimalIO, seekable=False)
|
||||
|
||||
def test_unpickling_buffering_readline(self):
|
||||
# Issue #12687: the unpickler's buffering logic could fail with
|
||||
|
|
|
@ -1384,6 +1384,11 @@ _Unpickler_ReadInto(UnpicklerObject *self, char *buf, Py_ssize_t n)
|
|||
if (!self->readinto) {
|
||||
/* readinto() not supported on file-like object, fall back to read()
|
||||
* and copy into destination buffer (bpo-39681) */
|
||||
if (PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||
"file-like object should provide readinto()",
|
||||
1) < 0) {
|
||||
return -1;
|
||||
}
|
||||
PyObject* len = PyLong_FromSsize_t(n);
|
||||
if (len == NULL) {
|
||||
return -1;
|
||||
|
|
Loading…
Reference in New Issue