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

Skip to content

Commit 90ce72d

Browse files
committed
Raise ValueError when attempting to set the _CHUNK_SIZE attribute of a TextIOWrapper to a huge value, not TypeError.
2 parents 8442124 + cb4ae81 commit 90ce72d

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
@@ -225,6 +225,9 @@ Core and Builtins
225225
Library
226226
-------
227227

228+
- Raise ValueError when attempting to set the _CHUNK_SIZE attribute of a
229+
TextIOWrapper to a huge value, not TypeError.
230+
228231
- Issue #12504: Close file handles in a timely manner in packaging.database.
229232
This fixes a bug with the remove (uninstall) feature on Windows.
230233

Modules/_io/textio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2618,7 +2618,7 @@ textiowrapper_chunk_size_set(textio *self, PyObject *arg, void *context)
26182618
{
26192619
Py_ssize_t n;
26202620
CHECK_INITIALIZED_INT(self);
2621-
n = PyNumber_AsSsize_t(arg, PyExc_TypeError);
2621+
n = PyNumber_AsSsize_t(arg, PyExc_ValueError);
26222622
if (n == -1 && PyErr_Occurred())
26232623
return -1;
26242624
if (n <= 0) {

0 commit comments

Comments
 (0)