Problem committing edits with arcpy.da.updatecursor

Discussion created by jg1295 on Jan 22, 2014
Latest reply on May 30, 2014 by jg1295
I'm having a whale of a time trying to use the arcpy.da.updatecursor while using an edit session to update the feature data.  Here's the problem:

I've got a script that is trying to update an unversioned point feature class in ArcSDE.  The user role has edit privileges to this specific FC.  I'll include the relevant bits of my code, but if you'd like to see the whole enchilada let me know and thanks in advance for your help.

Here, I'm querying webservice (inside the 'getNearestAddress' function) then building a dictionary with the result.  This works without error:
    with arcpy.da.SearchCursor(points, ('NEARBYADDRESS', 'BLOCK','STREET','SHAPE@X', 'SHAPE@Y', 'OID@')) as cursor:
        for row in cursor:
            #if row[5] < 100:
            thisoid = str(row[5])
            point_info = getNearestAddress(row[3], row[4])
            #returns a list like this ['Street Address','Block Description','Street Name'] or if no address found ['No Address Nearby']
            if str(point_info) == "No Address Nearby":
                myinfo[thisoid] = {"address" : "No Address Nearby"} 
                myinfo[thisoid]["block"] = "Unknown"
                myinfo[thisoid]["street"] = "Unknown"

                myinfo[thisoid] = {"address" : "".join(point_info[0])} #first value in the dictionary looks like this... create a key
                myinfo[thisoid]["block"] = "".join(point_info[1])
                myinfo[thisoid]["street"] = "".join(point_info[2])
                #the resulting dictionary of a couple of entries will look like this:
                #{123: {'address': "123 Main Street", 'block': "100 Block of Main Street", 'street': "Main Street"},
                #456: {'address': "456 South Street", 'block': "400 Block of South Street", 'street': "South Street"}}

Next, I try to populate the fields of the same FC using the info stored in the dictionary.  When the script gets to edit.stopOperation(), I get the error: error return without exception set:

    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(False, False)

    # Start an edit operation

    # Insert a row into the table.
    with arcpy.da.UpdateCursor(points, ('NEARBYADDRESS','BLOCK','STREET','OID@')) as cursor:
        for row in cursor:
            print "Currently on... " + str(row[3])
            if row[3] < 100:

                ##This will successfully save to the feature class!
                row[0] = "123 Dummy Address"
                row[1] = "100 Block of Dummy"
                row[2] = "Dummy"

                ##This will NOT save to the feature class!!
                row[0] = myinfo[str(row[3])]["address"]
                row[1] = myinfo[str(row[3])]["block"]
                row[2] = myinfo[str(row[3])]["street"]
                totalpointsupdated +=1
    # Stop the edit operation.  THIS IS WHERE THE ERROR OCCURS

    # Stop the edit session and save the changes