I've been going through and updating some old scripts from Python 2 to Python 3. These are typically very very minor changes, such as updating dictionary methods from old stuff like "viewitems" and "iteritems" to "items." I haven't changed anything in this script at all except now when I run it, when it hits lines with an UpdateCursor (hereforth, UC), it says the "in_table" is not a table or feature class. I have run Describe on feature class that I am passing to the UC to ensure that it is a feature class and it is. It is not participating in any joins, topologies, networks, network datasets or anything like that. It is coming from a file geodatabase. The documentation mentions something about "some" feature classes not working with class extensions and I wonder if that's my problem? This feature class does use domains, but I'm uncertain if the class extensions they're referring to in the documentation are custom class extensions and not the "out of the box" stuff. The last time this script worked, I was using ArcMap and Enterprise 10.7 I believe. I can alter my code to make a feature layer and give that to the UC and it works, but I don't understand why...
The code is really long, so I've tried to boil it down.
svyPtFC = os.path.join(uploadedGDB, "{0}_Patch_Template".format(stateID))
try:
#Check the projection of the input feature class.
prjInfo = inputDesc.spatialReference
if prjInfo.PCSCode != 102003:
#Project the feature class to match the Patches FC in the SDE database
spatialRef = arcpy.SpatialReference(102003) #USA Contiguous Albers Equal Area Conic EPSG code
svyPtFC = arcpy.Project_management(svyPtFC, os.path.join(scratchGDB, "projection"),
spatialRef)
except:
# do stuff
#Split multipart polygons to single part. Each polygon has to be evaluated separately. Multipart features would not work
#well when evaluating appropriate access or adjacency.
multipartFL = arcpy.MakeFeatureLayer_management(svyPtFC, 'multipartFL')
svyPtFC = arcpy.MultipartToSinglepart_management(multipartFL, os.path.join(scratchGDB, 'singlepart'))
#Find any gaps between polygons 1 meter wide or less and fix the polygon edges so they are coincident with each other.
svyPtFC = arcpy.Integrate_management(svyPtFC, '1 Meter')
##### FAILS HERE ######
# Check float fields for decimals. If there is a decimal, multiply by 100 to make it a whole number.
with arcpy.da.UpdateCursor(svyPtFC, ['CropResidue', 'CnpyOver12', 'CnpyDecid', 'CnpyConif', 'ShrubCover',
'ShbHiStemsDens','GrassCover', 'ForbCover', 'FrbAsProtect', 'BareGround']) as uCursor:
for row in uCursor:
for position, item in enumerate(row):
if item < 1 and item != 0 and item != None:
item = item * 100
row[position] = item
uCursor.updateRow(row)