I have a python script which walks through directories looking for layer files, in order to compile a list of layer files into a csv file. It crashes ArcGIS 10.4 (and also crashes Python when run via the command line) on accessing a particular layer file which retrieves data from an SQL table.
The problem in the layer file appears to be caused by the definition query in the layer file: when the layer has no definition query then the script is fine; when the layer has a definition query which returns no data then the script is also fine; however when the layer has a definition query which does return data then the script crashes. Other layer files exist which have the same definition query, but the script doesn't crash when accessing those other layers.
Recreating the layer from scratch hasn't worked. Has anyone run across a similar problem before?