mirror of
				https://github.com/psycopg/psycopg2.git
				synced 2025-10-30 23:37:29 +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; | ||||
| 
 | ||||
|     /* 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); | ||||
|     } | ||||
| 
 | ||||
|     self->copyfile = NULL; | ||||
|     Py_DECREF(file); | ||||
| 
 | ||||
| exit: | ||||
|     self->copyfile = NULL; | ||||
|     Py_XDECREF(file); | ||||
|     Py_XDECREF(sql); | ||||
| 
 | ||||
|     return res; | ||||
|  |  | |||
|  | @ -244,6 +244,15 @@ class CopyTests(unittest.TestCase): | |||
| 
 | ||||
|         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) | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user