Uploaded image for project: 'CUBRID APIs'
  1. CUBRID APIs
  2. APIS-482

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

    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 case: http://svn.cubrid.org/cubridapis/python/branches/RB-9.1.0/tests2/python/_13_exceptions/test_exceptions.py

      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" 
      

        Activity

        Hide
        jinhu 李金虎 added a comment -

        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

        Show
        jinhu 李金虎 added a comment - 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
        Hide
        jinhu 李金虎 added a comment -

        Merge into RB-9.1.0_static_cci, revision; 1649
        Merge into RB-8.4.1, revision; 1651
        Merge into RB-8.4.3, revision; 1652
        Merge into RB-8.4.3, revision; 1653
        Merge into trunk, revision: 1654

        Resolved.

        Show
        jinhu 李金虎 added a comment - Merge into RB-9.1.0_static_cci, revision; 1649 Merge into RB-8.4.1, revision; 1651 Merge into RB-8.4.3, revision; 1652 Merge into RB-8.4.3, revision; 1653 Merge into trunk, revision: 1654 Resolved.
        Hide
        cn14130 欧明宝[Bom Owen] added a comment -

        This issue has not exist

        Show
        cn14130 欧明宝[Bom Owen] added a comment - This issue has not exist

          People

          • Assignee:
            cn14130 欧明宝[Bom Owen]
            Reporter:
            cn14130 欧明宝[Bom Owen]
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: