Re: "ProgrammingError: can't adapt" when passing arguments to cursor.execute

Karsten Hilbert <[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
On Sat, Nov 21, 2009 at 12:52:34AM -0800, Eric Chamberlain wrote:

> Would this be useful?

Yes please !

Karsten

> Makes the error more specific.  This code is a joke as
> I've never programmed in C/C++ so please laugh at my expense
> :)  I also have no idea what the process is when submitting
> a patch (I can't seem to find a trac or other issue tracking
> system for this project).
> 
> patch for version 2.0.13
> psycopg/microprotocols.c
> @ line 116
> 
>     char warning[] = "can't adapt object type '%s'. hint: register adaptor for type using psycopg2.extensions.register_adaptor().";
>     /* -2 removes "%s" */
>     char buff[sizeof(obj->ob_type->tp_name) + (sizeof(warning) - 2)];
>     sprintf(buff, warning, obj->ob_type->tp_name);
> 
>     /* else set the right exception and return NULL */
>     psyco_set_error(ProgrammingError, NULL, buff, NULL, NULL);
> 
> It works when I compile it... cheers!
> 
> Eric Chamberlain
-- 
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.