SystemError: error return without exception set

308
6
05-28-2019 03:58 PM
JoeBorgione
MVP Esteemed Contributor

ArcGIS 10.6.1 Windows 10 64 bit.

I have a script tool that runs great until I process a certain table in a fgdb.  On two tables it works just fine, and does what I want it to, but when I get to the third table it tosses this error in the script tool window:

Traceback (most recent call last):
File "W:\GIS\DataCleanUp.py", line 134, in <module>
main()
File "W:\GIS\DataCleanUp.py", line 131, in main
cleanUp()
File "W:\GIS\DataCleanUp.py", line 105, in cleanUp
edit.stopOperation()
SystemError: error return without exception set

The script is set up in different def's() ; my cleanUp() def is what fails:

def cleanUp():

edit = arcpy.da.Editor(ws)
edit.startEditing(False,False) #use False False: with undo,(False) multiuser mode(False)
edit.startOperation()



tableFields = arcpy.ListFields(tableName,'','String')
try:
for f in tableFields:
fieldNames = []
fieldNames.append('{}'.format(f.name))
for fieldName in fieldNames:
field = [fieldName]
field.insert(0,'OBJECTID')
with arcpy.da.UpdateCursor(tableName,field) as updateRows:
for updateRow in updateRows:
if updateRow[1]== None:
pass
elif "\n" in updateRow[1]:
updateRow[1] = updateRow[1].replace("\n"," ==> ")
updateRows.updateRow(updateRow)
print('Success: Updated OID:{} in table:{} field:{}'.format(updateRow[0],tableName,field[1]))


except Exception as err:
print(err)
print('{} {}'.format(updateRow[0],updateRow[1]))
print('Error: Unable to process {} {}'.format(updateRow[0],field[1]))

# =============================================================================
edit.stopOperation()
edit.stopEditing(True)
print('Closed edit session')

It's called from main() and is the last in series of defs.

I write to a log file, but the errors I capture there are meaningless at best:

(1)The row contains a bad value. [SITENOTES]
(2)99 Safe for 1 sampler. Lots of human/dog activity. Easy to navigate
(3)Error: Unable to process 99 SITEVERIFY

(1) is the actual error from ArcGIS although I have no idea what record it fails on or why the [SITENOTES] field is noted

(2) is my error where I capture the the OID, and the contents of the field:  so for whatever reason it's telling me that OID 99 has a [SITENOTES] field value of: Safe for 1 sampler. Lots of human/dog activity. Easy to navigate

(3) is one of my error captures, and is baffling as well, since the SITEVERIFY field isn't even considered for OID 99 or any other.

Looking at the error that appears in script tool window, it complains about line 105 which is shown as line 33 in the cleanUp() def shown above.  My logic is to open the edit session, run the update cursor, and then close the edit session.  However, notice line 35 above:  it never does close the edit session.

After searching on SystemError: error return without exception set I don't quite understand what it means and/or how to mitigate for it.  Again, the weird thing about this mess is the script tool runs just fine on two other tables. It finds the newline character '\n' and replaces it with '==>' without a problem. This table though has been a problem child from the get go....

can't wait to retire....
0 Kudos
6 Replies
DEWright_CA
Occasional Contributor III

I find wrapping a Try/Catch deeper sometimes will get me more detail when the larger scale task is losing the context. In your case, try wrapping your:

with arcpy.da.UpdateCursor(tableName,field) as updateRows:

loop; to see if you might have something that is escaping the SQL process.

JoeBorgione
MVP Esteemed Contributor

I had moved the try/except around a a bit as well as the start/stop editing.  I'll give it another go.  Thanks.

can't wait to retire....
0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

side suggestions...

z = None  # ---- assign None to a variable

z == None # ---- equality checks for objects can't be guaranteed, ie np.nan
True

z is None # ---- it is, so be it
True

not z # ---- boolean checks are good
True
JoshuaBixby
MVP Esteemed Contributor

Just to confirm, it is a specific table regardless of the order, or is it always the third table regardless which order the tables are in?

0 Kudos
JoeBorgione
MVP Esteemed Contributor

Specific table.  I can't quite figure this one out; the process goes all the way through all the records and errors out.  If I delete the last record and then run the tool, it fails on what was the second last record.  I may split the table up into groups of records (like oid 1-50,51-100, etc) to see where if it's one record that is goofing on me...

can't wait to retire....
0 Kudos
JoshuaBixby
MVP Esteemed Contributor

I think your idea of chopping up the data set and testing each group is the right one.

0 Kudos