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

Skip to content

Commit cb4ae81

Browse files
committed
Raise ValueError when attempting to set the _CHUNK_SIZE attribute of a TextIOWrapper to a huge value, not TypeError.
1 parent fd06047 commit cb4ae81

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ Core and Builtins
2727
Library
2828
-------
2929

30+
- Raise ValueError when attempting to set the _CHUNK_SIZE attribute of a
31+
TextIOWrapper to a huge value, not TypeError.
32+
3033
- Issue #12493: subprocess: Popen.communicate() now also handles EINTR errors
3134
if the process has only one pipe.
3235

Modules/_io/textio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2556,7 +2556,7 @@ textiowrapper_chunk_size_set(textio *self, PyObject *arg, void *context)
25562556
{
25572557
Py_ssize_t n;
25582558
CHECK_INITIALIZED_INT(self);
2559-
n = PyNumber_AsSsize_t(arg, PyExc_TypeError);
2559+
n = PyNumber_AsSsize_t(arg, PyExc_ValueError);
25602560
if (n == -1 && PyErr_Occurred())
25612561
return -1;
25622562
if (n <= 0) {

0 commit comments

Comments
 (0)