]> granicus.if.org Git - python/commitdiff
SF patch #474175 (Jay T Miller): file.readinto arg parsing bug
authorGuido van Rossum <guido@python.org>
Tue, 23 Oct 2001 21:25:24 +0000 (21:25 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 23 Oct 2001 21:25:24 +0000 (21:25 +0000)
    The C-code in fileobject.readinto(buffer) which parses
    the arguments assumes that size_t is interchangeable
    with int:

    size_t ntodo, ndone, nnow;

    if (f->f_fp == NULL)
    return err_closed();
    if (!PyArg_Parse(args, "w#", &ptr, &ntodo))
    return NULL;

    This causes a problem on Alpha / Tru64 / OSF1 v5.1
    where size_t is a long and sizeof(long) != sizeof(int).

    The patch I'm proposing declares ntodo as an int.  An
    alternative might be to redefine w# to expect size_t.

[We can't change w# because there are probably third party modules
relying on it. GvR]

Misc/ACKS
Objects/fileobject.c

index 36e41e0421892e97d4ea5c328f84c1836ef72e0e..18bac30b7226e9e3ce3e7f3714ee33eedc75d2ad 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -279,6 +279,7 @@ Dieter Maurer
 Greg McFarlane
 Michael McLay
 Gordon McMillan
+Jay T. Miller
 Caolan McNamara
 Craig McPheeters
 Lambert Meertens
index 18f9ce2cc282ff97aa63abc42a15ffe1995474cb..cda5ff25bf22c0e835f2634aea0e3ba10976b0ce 100644 (file)
@@ -606,7 +606,8 @@ static PyObject *
 file_readinto(PyFileObject *f, PyObject *args)
 {
        char *ptr;
-       size_t ntodo, ndone, nnow;
+       int ntodo;
+       size_t ndone, nnow;
 
        if (f->f_fp == NULL)
                return err_closed();