Fixed error in register_type()

This commit is contained in:
Federico Di Gregorio 2009-03-02 10:56:53 +01:00
parent 4077711050
commit a3ce636be0
2 changed files with 7 additions and 3 deletions

View File

@ -1,5 +1,8 @@
2009-03-02 Federico Di Gregorio <fog@initd.org>
* psycopg/psycopgmodule.c: fixed unwanted exception when passing an
explicit None to register_type().
* psycopg/config.h: applied patch from Jason Erickson to build
with MSVC. Solaris version of isinf() is now a macro.

View File

@ -210,9 +210,10 @@ psyco_connect(PyObject *self, PyObject *args, PyObject *keywds)
/** type registration **/
#define psyco_register_type_doc \
"register_type(obj) -> None -- register obj with psycopg type system\n\n" \
"register_type(obj, conn_or_curs) -> None -- register obj with psycopg type system\n\n" \
":Parameters:\n" \
" * `obj`: A type adapter created by `new_type()`"
" * `obj`: A type adapter created by `new_type()`" \
" * `conn_or_curs`: A connection, cursor or None"
#define typecast_from_python_doc \
"new_type(oids, name, adapter) -> new type object\n\n" \
@ -243,7 +244,7 @@ psyco_register_type(PyObject *self, PyObject *args)
return NULL;
}
if (obj != NULL) {
if (obj != NULL && obj != Py_None) {
if (PyObject_TypeCheck(obj, &cursorType)) {
_psyco_register_type_set(&(((cursorObject*)obj)->string_types), type);
}