Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: Python-Aprium
-
Fix Version/s: None
-
Component/s: Python Driver
-
Labels:
-
Environment:
Linux x64
Description
[python] python driver throws exception which is can not catch when using cursor after connection close
test codes:
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')")
Test Result:
+ 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
This exception can not be catched
Exception AttributeError: "'Cursor' object has no attribute '_cs'" in <bound method Cursor.__del__ of <CUBRIDdb.cursors.Cursor object at 0x5302550>> ignored"
Solution:
When deleting cursor object, try to catch the AttributeError when the _cs member in cusor object dosen't exist.
Fixed in RB-9.1.0, revision: 1648