The following code will crash a Python interpreter, or crash the entire Arcmap app if run inside the python window or in a toolbox tool:import os, sys, time import arcpy def main(): #make a layer from scratch tfc = 'c:/arcview/sf/forest/tract.shp' strmap = '4301' t = 'tracts' df = arcpy.AddFieldDelimiters(tfc, 'MAP') exp = df + " = '" + strmap + "'" result = arcpy.MakeFeatureLayer_management(tfc, t, exp) lyr = result.getOutput(0) # or get a layer from a .lyr file with the same def query lyrfile = 'c:/temp/tract.lyr' lyr2 = arcpy.mapping.Layer(lyrfile) #either of the next 2 lines bombs python, or crashes Arcmap if inside app ext = lyr.getExtent() ext2 = lyr2.getExtent() if __name__ == '__main__': main()
The problem is the definition query, since both layers work fine without it. The query works, and GetCount returns 1 for each layer. This is 10.1, XP SP3. Any help would be appreciated.thanksMike