From 7d2109f9797515424fd1eeceddf883a30ed58bae Mon Sep 17 00:00:00 2001 From: Federico Di Gregorio Date: Mon, 13 Jun 2005 03:54:24 +0000 Subject: [PATCH] Don't segfault on empty queries anymore (closes: #24). --- ChangeLog | 7 +++++++ psycopg/cursor_type.c | 5 +++++ setup.py | 12 ++++++------ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1c8d9560..e1fc1263 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-06-13 Federico Di Gregorio + + * psycopg/cursor_type.c (_psyco_curs_execute): now checks for empty queries + and raise a ProgrammingError if appropriate (closes: #24). + + * setup.py: psycopg module renamed to psycopg2. + 2005-06-02 Federico Di Gregorio * psycopg/cursor_type.c (_psyco_curs_execute): fixed segfault when diff --git a/psycopg/cursor_type.c b/psycopg/cursor_type.c index ba139cfb..8cb5f2c6 100644 --- a/psycopg/cursor_type.c +++ b/psycopg/cursor_type.c @@ -237,6 +237,11 @@ _psyco_curs_execute(cursorObject *self, } pthread_mutex_unlock(&(self->conn->lock)); + if (!PyObject_IsTrue(operation)) { + PyErr_SetString(ProgrammingError, "can't execute an empty query"); + return 0; + } + if (PyUnicode_Check(operation)) { PyObject *enc = PyDict_GetItemString(psycoEncodings, self->conn->encoding); diff --git a/setup.py b/setup.py index a76aaf77..d1c17a04 100644 --- a/setup.py +++ b/setup.py @@ -318,26 +318,26 @@ if sys.platform == 'win32' and int(parser.get('build_ext', 'use_pg_dll')): sources = map(lambda x: os.path.join('psycopg', x), sources) -ext.append(Extension("psycopg._psycopg", sources, +ext.append(Extension("psycopg2._psycopg", sources, define_macros=define_macros, include_dirs=include_dirs, undef_macros=[])) -setup(name="psycopg", +setup(name="psycopg2", version=PSYCOPG_VERSION, maintainer="Federico Di Gregorio", maintainer_email="fog@initd.org", author="Federico Di Gregorio", author_email="fog@initd.org", - url="http://initd.org/software/initd/psycopg", - download_url = "http://initd.org/software/initd/psycopg", + url="http://initd.org/software/initd/psycopg2", + download_url = "http://initd.org/software/initd/psycopg2", license="GPL or ZPL", platforms = ["any"], description=__doc__.split("\n")[0], long_description="\n".join(__doc__.split("\n")[2:]), classifiers=filter(None, classifiers.split("\n")), data_files=data_files, - package_dir={'psycopg':'lib'}, - packages=['psycopg'], + package_dir={'psycopg2':'lib'}, + packages=['psycopg2'], cmdclass={ 'build_ext': psycopg_build_ext }, ext_modules=ext)