deleteRow() return SystemError: error return without exception set

2188
11
09-13-2016 09:32 AM
FredericPiche
New Contributor II

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

0 Kudos
11 Replies
DanPatterson_Retired
MVP Esteemed Contributor

Your code is unreadable, you need to use Python syntax highlighting... follow the ... (3 dots), then select More, then 

syntax highlighting, python, and paste your code inside and save.

FredericPiche
New Contributor II

thanks, i was looking for that but didn't know it was under highlighting. updated

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

You seem to have narrowed down the issue quite a bit, I recommend contacting Esri Support to see if this is a bug.

Beyond contacting Esri Support, working with coverages continues to get more and more tenuous with each version of ArcGIS for Desktop.  Given that the ArcPy Data Access module was introduced back in ArcGIS 10.1, it could be the locking doesn't quite work with coverages because coverages would not have been a focus of the new cursors.  Have you tried a similar workflow using the original cursors, the ones that pre-date the arcpy.da cursors?

If you try your exact same workflow on shapefiles and feature classes in a file geodatabase, does it work?  If so, then it likely points to an issue with coverages.  If not, then the problem lies somewhere in the code and how cursors are being handled.

FredericPiche
New Contributor II

I don't have a shapefile or geodatabase right now available to me, i cannot test that.

i did test the old arcpy.updatecursor, see my question for the result

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

My guess, it is a "coverage thing."  Even if you contact Esri Support and they log a bug, I don't believe it will be addressed given the problem is with coverages.  My advice is to migrate the data from coverages to feature classes in a file geodatabase.

Regarding shapefiles and geodatabases for testing, if you have a license to use ArcPy Data Access cursors, you have all of the tools available for creating shapefiles and feature classes to test them.

FredericPiche
New Contributor II

I did a quick test (converted one of my coverage into gdb) and i am able to delete a row.

I hope to make my delete work on the coverage since I need to do a clean_arc after deleting stuff

the clean_arc doesn't seem to work on a geodatabase file

0 Kudos
FredericPiche
New Contributor II

also converting to gdb change the shape(geometry) values, losing precision

0 Kudos
NeilAyres
MVP Frequent Contributor

Just to be a little picky about naming variables....

This is a list of field objects (not a straight list) :

fieldList = arcpy.ListFields(feature)

This is a list of strings (not a string) :

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

I must agree with Joshua. Coverages, really.... Havn't met one of those for a very looong time.

0 Kudos
FredericPiche
New Contributor II

right now i 'm just trying to do a delete, naming convention and everything else will follow ;)