string containing raw data - PyArg_ParseTuple() bug?

Richard Bouska xbouska at bsdi.infima.cz
Fri May 7 02:15:21 EDT 1999


Well the db is the postgresql ver 6.4-2 and the interface I am using is
PyGreSQL-2.3. I made the changes you suggested and I will send them to the
author.

Thank You very much for Your assistance.
I am not the autor of the PyGreSQL and did not expect "feature" like that.

Richard Bouska
Richard at Bouska.cz


On Thu, 6 May 1999, Christian Tismer wrote:

> 
> 
> Richard Bouska wrote:
> > 
> > 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)
> 
> Could you please provide us with more info about "db"?
> Did you write the interface yourself?
> 
> >         if (!PyArg_ParseTuple (args, "s", &buffer))
> 
> This has the semantics that the string must be a properly
> zero terminated string. If you call this with a string
> object with zeroes, PyArg_ParseTuple correctly complains.
> 
> If your intent is to work with raw strings which can
> contain anything, use
> 
> >         if (!PyArg_ParseTuple (args, "s#", &buffer, &buflen))
> 
> ciao - chris
> 
> -- 
> Christian Tismer             :^)   <mailto:tismer at appliedbiometrics.com>
> Applied Biometrics GmbH      :     Have a break! Take a ride on Python's
> Kaiserin-Augusta-Allee 101   :    *Starship* http://starship.python.net
> 10553 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
> PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
>      we're tired of banana software - shipped green, ripens at home
> 





More information about the Python-list mailing list