Don't segfault on empty queries anymore (closes: #24).

This commit is contained in:
Federico Di Gregorio 2005-06-13 03:54:24 +00:00
parent 7ead773fc0
commit 7d2109f979
3 changed files with 18 additions and 6 deletions

View File

@ -1,3 +1,10 @@
2005-06-13 Federico Di Gregorio <fog@initd.org>
* 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 <fog@debian.org> 2005-06-02 Federico Di Gregorio <fog@debian.org>
* psycopg/cursor_type.c (_psyco_curs_execute): fixed segfault when * psycopg/cursor_type.c (_psyco_curs_execute): fixed segfault when

View File

@ -237,6 +237,11 @@ _psyco_curs_execute(cursorObject *self,
} }
pthread_mutex_unlock(&(self->conn->lock)); 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)) { if (PyUnicode_Check(operation)) {
PyObject *enc = PyDict_GetItemString(psycoEncodings, PyObject *enc = PyDict_GetItemString(psycoEncodings,
self->conn->encoding); self->conn->encoding);

View File

@ -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) 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, define_macros=define_macros,
include_dirs=include_dirs, include_dirs=include_dirs,
undef_macros=[])) undef_macros=[]))
setup(name="psycopg", setup(name="psycopg2",
version=PSYCOPG_VERSION, version=PSYCOPG_VERSION,
maintainer="Federico Di Gregorio", maintainer="Federico Di Gregorio",
maintainer_email="fog@initd.org", maintainer_email="fog@initd.org",
author="Federico Di Gregorio", author="Federico Di Gregorio",
author_email="fog@initd.org", author_email="fog@initd.org",
url="http://initd.org/software/initd/psycopg", url="http://initd.org/software/initd/psycopg2",
download_url = "http://initd.org/software/initd/psycopg", download_url = "http://initd.org/software/initd/psycopg2",
license="GPL or ZPL", license="GPL or ZPL",
platforms = ["any"], platforms = ["any"],
description=__doc__.split("\n")[0], description=__doc__.split("\n")[0],
long_description="\n".join(__doc__.split("\n")[2:]), long_description="\n".join(__doc__.split("\n")[2:]),
classifiers=filter(None, classifiers.split("\n")), classifiers=filter(None, classifiers.split("\n")),
data_files=data_files, data_files=data_files,
package_dir={'psycopg':'lib'}, package_dir={'psycopg2':'lib'},
packages=['psycopg'], packages=['psycopg2'],
cmdclass={ 'build_ext': psycopg_build_ext }, cmdclass={ 'build_ext': psycopg_build_ext },
ext_modules=ext) ext_modules=ext)