English

Bug: Error 000317: Topology within feature dataset cannot be deleted

Description

When attempting to delete a feature dataset containing a topology, an error message is returned. The feature dataset is deleted as well.
[O-Image]

Code:
import arcpy
arcpy.env.workspace = r"C:\data\test.gdb"
arcpy.Delete_management("majorrds")

Cause

This is a known issue. The software attempts to warn the user when a topology exists in the feature dataset, which must be deleted before deleting the feature dataset. However, since the topology is a part of the feature dataset itself, it is deleted and the error message is generated.

Workaround

Use the 'try:' and 'except:' statements to bypass the error and move forward with the execution of the script.

Insert the following code. Be sure to adjust the file path of the location of the dataset.

Code:
import arcpy
arcpy.env.workspace = r"C:\data\test.gdb"
try:
arcpy.Delete_management("majorrds")
print "copied zoning"
except:
print "A warning was generated"