Menu

#435 [python] python driver throws exception which is can not catch when using cursor after connection close

open
nobody
None
5
2013-03-07
2013-03-07
Jira Trac
No

[python] python driver throws exception which is can not catch when using cursor after connection close

Test case: http://svn.cubrid.org/cubridapis/python/branches/RB-9.1.0/tests2/python/_13_exceptions/test_exceptions.py

test codes:
{noformat}
def test_01Exceptions(self):
con = self.con
error = 0
errorValue = ''
try:
cur = con.cursor()
cur.execute(insert into exceptions_t values error_sql('Hello') )
except CUBRIDdb.DatabaseError, e:
error = 1
errorValue = str(e)
finally:
con.close()
#print sys.stderr, \nException...Error %d: %s % (e.args[0], e.args[1])
self.assertEqual(error, 1, catch one except.)
#print \n, e.args[0]
#print \n, errorValue
self.assertEquals(errorValue,(-493, \ERROR: DBMS, -493, Syntax: In line 1, column 33 before \'(\'Hello\') \'\\nSyntax error: un
expected \'error_sql\', expecting \'(\' \))

error = 0
errorValue = ''
try:
cur = con.cursor()
cur.fetchone()
cur.execute(insert into exceptions_t values ('forrollback',6,66, 10) )
except CUBRIDdb.Error, e:
error = 1
errorValue = str(e)
#print sys.stderr, \nException...Error %d: %s % (e.args[0], e.args[1])
except Exception,e1:
print \n,str(e1)
self.assertEqual(error, 1, catch one except. OK.)
self.assertEquals(errorValue, (-20002, 'ERROR: CCI, -20002, Invalid connection handle'))
{noformat}

Test Result:
{noformat}
+ python python/_13_exceptions/test_exceptions.py
test_01Exceptions (__main__.ExceptionsTest) ... Exception AttributeError: 'Cursor' object has no attribute '_cs' in bound method Cursor.__del__ of CUBRIDdb.cursors.Cursor object at 0x5302550 ignored
ok
test_02Exceptions (__main__.ExceptionsTest) ...
connect url is empty
ok

----------------------------------------------------------------------
Ran 2 tests in 0.066s

OK
{noformat}

This exception can not be catched
{noformat}
Exception AttributeError: 'Cursor' object has no attribute '_cs' in bound method Cursor.__del__ of CUBRIDdb.cursors.Cursor object at 0x5302550 ignored
{noformat}

Discussion

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.