Skip to content

Commit bb5185d

Browse files
committed
fix: drop wrong fix
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
1 parent 6f5c111 commit bb5185d

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

Modules/_io/textio.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,22 +2416,13 @@ typedef struct {
24162416
#endif
24172417

24182418
static int
2419-
textiowrapper_parse_cookie(textio *self, cookie_type *cookie, PyObject *cookieObj)
2419+
textiowrapper_parse_cookie(cookie_type *cookie, PyObject *cookieObj)
24202420
{
24212421
unsigned char buffer[COOKIE_BUF_LEN];
24222422
PyLongObject *cookieLong = (PyLongObject *)PyNumber_Long(cookieObj);
24232423
if (cookieLong == NULL)
24242424
return -1;
24252425

2426-
// gh-143007: PyNumber_Long can call arbitrary code through __int__
2427-
// which may detach the underlying buffer.
2428-
if (self->detached) {
2429-
Py_DECREF(cookieLong);
2430-
PyErr_SetString(PyExc_ValueError,
2431-
"underlying buffer has been detached");
2432-
return -1;
2433-
}
2434-
24352426
if (_PyLong_AsByteArray(cookieLong, buffer, sizeof(buffer),
24362427
PY_LITTLE_ENDIAN, 0, 1) < 0) {
24372428
Py_DECREF(cookieLong);
@@ -2646,7 +2637,7 @@ _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence)
26462637
/* The strategy of seek() is to go back to the safe start point
26472638
* and replay the effect of read(chars_to_skip) from there.
26482639
*/
2649-
if (textiowrapper_parse_cookie(self, &cookie, cookieObj) < 0)
2640+
if (textiowrapper_parse_cookie(&cookie, cookieObj) < 0)
26502641
goto fail;
26512642

26522643
/* Seek back to the safe start point. */

0 commit comments

Comments
 (0)