string containing raw data - PyArg_ParseTuple() bug?

Richard Bouska xbouska at infima.cz
Thu May 6 09:24:56 EDT 1999


I have a problem with when I want to copy a file to databaze:
	lo=db.locreate(pg.INV_READ|pg.INV_WRITE)
        lo.open(pg.INV_WRITE)
        buf=f.read(8192)
        while buf:
            lo.write(buf)
            buf=f.read(8192)
        lo.close()

but I got the folowing error:

lo.write(buf)
TypeError: write(buffer), with buffer (sized string)

The proble arises only if the source file are raw data for ASCII texts
is the script working well.

The part of the c underlying c code:
	  /* gets arguments */
        if (!PyArg_ParseTuple (args, "s", &buffer))
        {
                PyErr_SetString(PyExc_TypeError,
                                "write(buffer), with buffer (sized
string).");
                return NULL;
        }

If I understat it corectly thr problem is in the PyArg_ParseTuple
function. 

Richard Bouska
Richard at Bouska.cz




More information about the Python-list mailing list