Fixed error in fetchXXX methods

This commit is contained in:
Federico Di Gregorio 2009-05-09 14:28:40 +02:00
parent 06eb574cec
commit 3935c019fe
3 changed files with 17 additions and 9 deletions

View File

@ -1,5 +1,8 @@
2009-05-10 Federico Di Gregorio <fog@initd.org> 2009-05-10 Federico Di Gregorio <fog@initd.org>
* psycopg/cursor_ext.c: now raise correct exception when fetching
using a custom row factory results in an error.
* lib/extras.py: applied DictRow "diet" patch from Marko Kreen. * lib/extras.py: applied DictRow "diet" patch from Marko Kreen.
2009-04-21 Federico Di Gregorio <fog@initd.org> 2009-04-21 Federico Di Gregorio <fog@initd.org>

View File

@ -326,7 +326,7 @@ _psyco_curs_execute(cursorObject *self,
/* Any failure from here forward should 'goto fail' rather than 'return 0' /* Any failure from here forward should 'goto fail' rather than 'return 0'
directly. */ directly. */
if (operation == NULL) { goto fail; } if (operation == NULL) { goto fail; }
IFCLEARPGRES(self->pgres); IFCLEARPGRES(self->pgres);
@ -425,7 +425,7 @@ _psyco_curs_execute(cursorObject *self,
} }
/* At this point, the SQL statement must be str, not unicode */ /* At this point, the SQL statement must be str, not unicode */
res = pq_execute(self, PyString_AS_STRING(self->query), async); res = pq_execute(self, PyString_AS_STRING(self->query), async);
Dprintf("psyco_curs_execute: res = %d, pgres = %p", res, self->pgres); Dprintf("psyco_curs_execute: res = %d, pgres = %p", res, self->pgres);
if (res == -1) { goto fail; } if (res == -1) { goto fail; }
@ -713,8 +713,13 @@ _psyco_curs_buildrow_fill(cursorObject *self, PyObject *res,
PyTuple_SET_ITEM(res, i, val); PyTuple_SET_ITEM(res, i, val);
} }
else { else {
PySequence_SetItem(res, i, val); int err = PySequence_SetItem(res, i, val);
Py_DECREF(val); Py_DECREF(val);
if (err == -1) {
Py_DECREF(res);
res = NULL;
break;
}
} }
} }
else { else {

View File

@ -7,7 +7,7 @@
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{CFD80D18-3EE5-49ED-992A-E6D433BC7641}</ProjectGuid> <ProjectGuid>{CFD80D18-3EE5-49ED-992A-E6D433BC7641}</ProjectGuid>
<Compiler> <Compiler>
<Compiler ctype="GccCompiler" xmlns="" /> <Compiler ctype="GccCompiler" />
</Compiler> </Compiler>
<Language>C</Language> <Language>C</Language>
<Target>Bin</Target> <Target>Bin</Target>
@ -17,11 +17,11 @@
<OutputPath>.</OutputPath> <OutputPath>.</OutputPath>
<DefineSymbols>DEBUG MONODEVELOP</DefineSymbols> <DefineSymbols>DEBUG MONODEVELOP</DefineSymbols>
<CodeGeneration> <CodeGeneration>
<CodeGeneration ctype="CCompilationParameters" xmlns="" /> <CodeGeneration ctype="CCompilationParameters" />
</CodeGeneration> </CodeGeneration>
<CompileTarget>Bin</CompileTarget> <CompileTarget>Bin</CompileTarget>
<CustomCommands> <CustomCommands>
<CustomCommands xmlns=""> <CustomCommands>
<Command type="Build" command="/usr/bin/python setup.py build" workingdir="${ProjectDir}" /> <Command type="Build" command="/usr/bin/python setup.py build" workingdir="${ProjectDir}" />
<Command type="Clean" command="/usr/bin/python setup.py clean -a" workingdir="${ProjectDir}" /> <Command type="Clean" command="/usr/bin/python setup.py clean -a" workingdir="${ProjectDir}" />
</CustomCommands> </CustomCommands>
@ -32,7 +32,7 @@
<OutputPath>bin\Release</OutputPath> <OutputPath>bin\Release</OutputPath>
<DefineSymbols>MONODEVELOP</DefineSymbols> <DefineSymbols>MONODEVELOP</DefineSymbols>
<CodeGeneration> <CodeGeneration>
<CodeGeneration ctype="CCompilationParameters" xmlns="" /> <CodeGeneration ctype="CCompilationParameters" />
</CodeGeneration> </CodeGeneration>
<OptimizationLevel>3</OptimizationLevel> <OptimizationLevel>3</OptimizationLevel>
<OutputName>psycopg2</OutputName> <OutputName>psycopg2</OutputName>
@ -170,12 +170,12 @@
</ItemGroup> </ItemGroup>
<ProjectExtensions> <ProjectExtensions>
<MonoDevelop> <MonoDevelop>
<Properties xmlns=""> <Properties>
<Policies> <Policies>
<ChangeLogPolicy UpdateMode="Nearest" VcsIntegration="None" inheritsSet="Mono"> <ChangeLogPolicy UpdateMode="Nearest" VcsIntegration="None" inheritsSet="Mono">
<MessageStyle FileSeparator=", " LineAlign="0" /> <MessageStyle FileSeparator=", " LineAlign="0" />
</ChangeLogPolicy> </ChangeLogPolicy>
<TextStylePolicy FileWidth="120" TabWidth="4" TabsToSpaces="False" NoTabsAfterNonTabs="False" RemoveTrailingWhitespace="True" EolMarker="Native" /> <TextStylePolicy FileWidth="144" TabWidth="4" TabsToSpaces="True" NoTabsAfterNonTabs="False" RemoveTrailingWhitespace="True" EolMarker="Native" />
</Policies> </Policies>
</Properties> </Properties>
</MonoDevelop> </MonoDevelop>