mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-17 01:20:32 +03:00
Merge branch 'copy-refcount-bug' into devel
This commit is contained in:
commit
816b5dda33
|
@ -1505,14 +1505,15 @@ psyco_curs_copy_expert(cursorObject *self, PyObject *args, PyObject *kwargs)
|
||||||
self->copyfile = file;
|
self->copyfile = file;
|
||||||
|
|
||||||
/* At this point, the SQL statement must be str, not unicode */
|
/* At this point, the SQL statement must be str, not unicode */
|
||||||
if (pq_execute(self, Bytes_AS_STRING(sql), 0) != 1) { goto exit; }
|
if (pq_execute(self, Bytes_AS_STRING(sql), 0) == 1) {
|
||||||
|
res = Py_None;
|
||||||
|
Py_INCREF(res);
|
||||||
|
}
|
||||||
|
|
||||||
res = Py_None;
|
self->copyfile = NULL;
|
||||||
Py_INCREF(res);
|
Py_DECREF(file);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
self->copyfile = NULL;
|
|
||||||
Py_XDECREF(file);
|
|
||||||
Py_XDECREF(sql);
|
Py_XDECREF(sql);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -244,6 +244,15 @@ class CopyTests(unittest.TestCase):
|
||||||
|
|
||||||
self.assertEqual(ntests, len(string.ascii_letters))
|
self.assertEqual(ntests, len(string.ascii_letters))
|
||||||
|
|
||||||
|
def test_copy_expert_file_refcount(self):
|
||||||
|
class Whatever(object):
|
||||||
|
pass
|
||||||
|
|
||||||
|
f = Whatever()
|
||||||
|
curs = self.conn.cursor()
|
||||||
|
self.assertRaises(TypeError,
|
||||||
|
curs.copy_expert, 'COPY tcopy (data) FROM STDIN', f)
|
||||||
|
|
||||||
decorate_all_tests(CopyTests, skip_if_green)
|
decorate_all_tests(CopyTests, skip_if_green)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user