AnsweredAssumed Answered

deleteRow() return SystemError: error return without exception set

Question asked by Fredou on Sep 13, 2016
Latest reply on Sep 15, 2016 by Fredou

I'm trying to delete a row from a coverage

I'm using arcpy 10.3.1

 

the code that i am using is (to be able to reproduce the issue)

 

import arcpy

def count_row(data):
    i = 0
    for row in data:
        i += 1

    data.reset()

    return i

arcpy.env.workspace = 'C:/Data/cea01apr'
feature = 'point'
fidfilter= 'fid = 1'

featureClassList = arcpy.ListFeatureClasses()

fieldList = arcpy.ListFields(feature)
fieldString = [str(x.name) for x in fieldList]

with arcpy.da.UpdateCursor(feature, fieldString, fidfilter) as cursorupdate:
    print('Number of rows:' + str(count_row(cursorupdate)))
    rowupdate = cursorupdate.next()
    print(rowupdate[12])

    rowupdate[12] +=  'h'
    cursorupdate.updateRow(rowupdate)

with arcpy.da.SearchCursor(feature, fieldString, fidfilter) as cursorupdate:
    print('Number of rows:' + str(count_row(cursorupdate)))
    rowupdate = cursorupdate.next()

    if rowupdate:
        print(rowupdate[12])

with arcpy.da.UpdateCursor(feature, fieldString, fidfilter) as cursorupdate1:
    print('Number of rows:' + str(count_row(cursorupdate1)))
    for row in cursorupdate1:
        cursorupdate1.deleteRow()

raw_input('Press the <ENTER> key to exit')

 

the output of that script is

 

C:\Data>test.py
Number of rows:1
hhhhhhhhhhhhhhhh
Number of rows:1
hhhhhhhhhhhhhhhhh
Number of rows:1
Traceback (most recent call last):
  File "C:\Data\test.py", line 39, in <module>
    cursorupdate1.deleteRow()
SystemError: error return without exception set

 

I have tried this

arcpy.MakeTableView_management(feature, 'test')
arcpy.SelectLayerByAttribute_management('test', 'NEW_SELECTION', fidfilter)
arcpy.DeleteRows_management('test')

 

and i'm getting this error

 

Traceback (most recent call last):
  File "C:\Data\test.py", line 41, in <module>
    arcpy.DeleteRows_management('test')
  File "C:\***\cots\ArcGIS\Desktop10.3\ArcPy\arcpy\management.py", line 15352, in DeleteRows
    raise e
arcgisscripting.ExecuteError: ERROR 999999: Error executing function.
Failed to execute (DeleteRows).

 

trying the old arcpy.UpdateCursor

 

cursorupdate2 =  arcpy.UpdateCursor(feature)
#print('Number of rows:' + str(count_row(cursorupdate2)))
row = cursorupdate2.next()
print('delete')
cursorupdate2.deleteRow(row)

will result into

 

C:\Data>test.py
ArcInfo
Number of rows:1
hhhhhhhhhhhhhhhhhhhh
Number of rows:1
hhhhhhhhhhhhhhhhhhhhh
delete
Traceback (most recent call last):
  File "C:\Data\test.py", line 56, in <module>
    cursorupdate2.deleteRow(row)
  File "C:\***\cots\ArcGIS\Desktop10.3\ArcPy\arcpy\arcobjects\arcobjects.py", line 110, in deleteRow
    return convertArcObjectToPythonObject(self._arc_object.DeleteRow(*gp_fixargs(args)))
RuntimeError: ERROR 999999: Error executing function.

 

uncommenting the line for the number of rows will actually crash python.exe

Outcomes