[GIS] arcpy.env.overwriteOutput = True not working for one dataset

arcpycopyenterprise-geodatabase

I am doing a basic copy from sde database to file geodatabase. I have a loop going through each feature dataset in the sde database, this loop is really basic it just uses arcpy.Copy_Management to copy everything over. I have arcpy.env.overwriteOutput = True at the beginning of the script after importing in arcpy. It does not throw me that error for any other feature dataset, even though they are also overwriting a FeatureDataset with the same name.

the error it throws is :

ERROR 000605: Output Sidewalk already exists within
C:\Users\stack\Desktop\Testing\scripts\Dump.gdb\Sidewalk. Failed to
execute (Copy).

I even added arcpy.env.overwriteOutput = True to the beginning to of the function. I also put a line in the exception the prints out the status of env.overwriteOutput and it is true at that time when it breaks.

This does not make any sense to me. Has anyone else had this problem?

Best Answer

As discussed in the comments, this appears to be a bug of some sort. Use the workaround Exists \ Delete method:

if arcpy.Exists (fc): 
    arcpy.Delete_management (fc)
Related Question