error return without exception set

20542
17
04-14-2014 10:35 AM
TonyAlmeida
Occasional Contributor II
I have the following code.
The code works great on a shapefile but as soon as i change the workspace to a SDE sqlexpress datatbase i get the following error.
Traceback (most recent call last):
  File "C:\GIS\Python Scripts\AddressPoints\Point_2_Ca.py", line 125, in <module>
    edit.stopOperation()
SystemError: error return without exception set


The error is not specific on where the problem is, I've searched but i am unable to find the problem. where is the problem and how can i fix it to run with out errors?
As i mentioned before the code runs great against a shapefile and running against a shapefile takes about 4-6 seconds.
When i switch it to a SDE sqlexpress datatbase it takes 4 minutes then runs into the error. There is only 48 features in the SDE sqlexpress datatbase so the database is not very big. Why is this?


import arcpy
from arcpy import env
import time
import datetime
import pythonaddins
import os

fc = "TonyTwoWay.DBO.TT"
workspace = r"Database Servers\DSD15_SQLEXPRESS.gds\TonyTwoWay (VERSION:dbo.DEFAULT)"
arcpy.env.overwriteOutput = True
arcpy.env.qualifiedFieldNames = False

# Start an edit session. Must provide the worksapce.
edit = arcpy.da.Editor(workspace)

# Edit session is started without an undo/redo stack for versioned data
#  (for second argument, use False for unversioned data)
edit.startEditing(True)

# Start an edit operation
edit.startOperation()

input = arcpy.GetParameterAsText(0)

rows = arcpy.SearchCursor(input)
for row in rows:
    geom = row.Shape
    X = geom.centroid.X
    Y = geom.centroid.Y
del rows, row
   
row_values = (X, Y, (X, Y))
cursor = arcpy.da.InsertCursor(fc, ["X_Coord", "Y_Coord", "SHAPE@XY"])
cursor.insertRow(row_values)
del cursor

####Select by location on parcels with created point
Parcellyr = "Taxparcels"

arcpy.MakeFeatureLayer_management(Parcellyr, "in_memory\Parcel layer")
entries = int(arcpy.GetCount_management(fc).getOutput(0))

for i in xrange(entries):
    arcpy.MakeFeatureLayer_management(fc, "in_memory\point layer", "\"OBJECTID\"={}".format(str(i) + ""))
    arcpy.SelectLayerByLocation_management("in_memory\Parcel layer", "INTERSECT", "in_memory\point layer", "", "NEW_SELECTION")
    #if arcpy.Exists(pt_lyr): arcpy.Delete_management(pt_lyr) 

arcpy.CopyFeatures_management("in_memory\Parcel layer", "in_memory\Sel_Par")
table = "Vector.DBO.PARCELADMIN"
try:
    arcpy.AddJoin_management("in_memory\Sel_Par", "ACCOUNT", table, "Acct", "KEEP_COMMON")
except BaseException as e:
    pass

arcpy.CopyFeatures_management("in_memory\Sel_Par","in_memory\ParLYR")
arcpy.MakeFeatureLayer_management("in_memory\ParLYR", "in_memory\Par")


#### populates fields

add_fields = ["ACCOUNT","SiteNum","OwnerName","SiteAddres","SiteNumSfx","SiteStreet","Predir","StreetType","Postdir", "SubName", "SiteCity", "SiteZip", "SubName"]

# fix args
if not isinstance(add_fields, list):
    # from script tool
    add_fields = add_fields.split(';')

# do not need this scratch file
fcOutput = r'C:\Temp\Default.gdb\temp_join' #'temp_join' when using workspace = r"C:\Temp\default.gdb"
arcpy.SpatialJoin_analysis("in_memory\Par", "in_memory\point layer", fcOutput, 'JOIN_ONE_TO_MANY', 'KEEP_COMMON')

# grab oid field from points
oid_t = arcpy.Describe(fc).OIDFieldName

Field4 = "SubNum" #Field from spaital Join
Field4a = "SiteSubNum"
#Field5 = "City" #Field from spaital Join
#Field5a = "BusinsName"

# init rowW and rowR
curR = arcpy.SearchCursor(fcOutput)
join_dict = dict([(r.JOIN_FID,[r.getValue(f) for f in add_fields]) for r in curR])
del curR

Fields = ["SubNum","City",]

rows = arcpy.da.SearchCursor(fcOutput, Fields)
for row in rows:
    Num1 = rows[0]
    #Num2 = rows[1]
    
# Now update the new target
curW = arcpy.UpdateCursor(fc)
for row in curW:
    t_oid = row.getValue(oid_t)
    if t_oid in join_dict:
        for f in add_fields:
            row.setValue(f, join_dict[t_oid][add_fields.index(f)])
            row.setValue('GIS_STEW', "Canyon Co")
            row.setValue('IssuedBy', "TA")
            row.setValue('Status', "Active")
            row.setValue('StartDate', datetime.datetime.now().strftime('%m/%d/%Y'))
            row.setValue('SiteState', "ID")
            row.setValue('SiteCounty', "Canyon")
            row.setValue('StreetName', row.SiteStreet + " " + row.StreetType)
            row.setValue('Verified', "Yes,TA")
            row.setValue(Field4a, Num1)
            #row.setValue(Field5a, Num2)
        #else:
            #row.StreetName = curR.SiteStreet
    curW.updateRow(row)
del row, curW, rows


#arcpy.SelectLayerByAttribute_management(Parcellyr, "CLEAR_SELECTION")
arcpy.Delete_management("in_memory\Parcel layer")
arcpy.Delete_management("in_memory\point layer")
arcpy.Delete_management("in_memory\Sel_Par")
arcpy.Delete_management("in_memory\ParLYR")
arcpy.Delete_management("in_memory\Par")
#arcpy.Delete_management(r'in_memory\temp_join')

# Stop the edit operation.
edit.stopOperation()

# Stop the edit session and save the changes
edit.stopEditing(True)
              
Tags (2)
17 Replies
JulianInskip
Occasional Contributor

I am also having an issue with this, but for me it is when I run my script as a GP Service (no problems when running it in ArcMap). My error comes when I edit.startEditing(False, True) - and yes, my data is versioned (in a feature dataset if that makes a difference).

I am not 100% sure, but it might be something to do with the numpy version. I have not tried this yet so I am not sure if upgrading to a more recent version of numpy will either break my ArcMap, python or if it will actually make a difference with this error. I will try and test this on a VM first and will post back here.

Might also be a thing between running the script using python 32bit and python 64bit.

"SystemError: error return without exception set" when indexing with -1 · Issue #4285 · scipy/scipy ...

0 Kudos
CallumSmith2
Occasional Contributor

Hi Just a note on this that may help others. I had this error exactly as explained in the original post writing to a SDE featureclass and it turned out the issue was a length of a field. I had a text field length 10 and was trying to write some text to it that was longer than 10. The cursor ran through without a problem but when I tried to commit the edits with editor.StopOperation I got the error "SystemError: error return without exception set". To resolve the issue all I had to do was make the text field larger.

cheers

Callum

South_JordanCity_of
Occasional Contributor

Callum,

you nailed it! After truncating some values to the max field length, the edit operation was successful.

Cheers!

Marc

deleted-user-st4HsVxccxgs
New Contributor III

Callum,

This was also the problem for me. One sneaky field in the midst of dozens that was just a little short in field length. Very difficult to diagnose without trying to edit values in each field. 

Thanks!

0 Kudos
ChaimSchwartz3
New Contributor II

Helped me too, thanks!

0 Kudos
CarlosRibeiro
New Contributor III

For me it happend when I ran my script for populating a turntable which made part of a network dataset, by copying the features from another feature class not belonging to the netowrk. After some tests, I finally found out the cause of getting the useless message SystemError: error return without exception set:  eventhough I had added the turntable to the network before it being populated, I didn't rebuilt it .

So, I ran Build Network GP and the script worked like a charm!

 

0 Kudos
CynthiaRoush2
New Contributor II

Thank you so much, Callum! I was getting this error ("SystemError: error return without exception set") while simply calculating centroid coordinates using CalculateGeometry (through arcpy). Your entry here helped me realize I needed to change the field type from FLOAT to DOUBLE.

0 Kudos
RogerDunnGIS
Occasional Contributor II

I am working with arcpy in Python 3.7.11 and ArcGIS Pro 2.9.5.  I was getting this error: "SystemError: <method 'stopOperation' of 'Workspace Editor' objects> returned NULL without setting an error"  The problem was that I was putting a string value into a text field which was too long.  The field was 15 characters, but the value was 19 characters.  Since the error message doesn't mention anything about that, I only found the problem when I decided to print the values of the row!  I hope this helps someone else.

0 Kudos