I learned that I need to close objects that I open, usually using a
with open(): statement that does the closing for you after leaving it. With GDAL/OGR, this does not work and objects must be closed manually. In GDAL, this works by
from osgeo import gdal ds = gdal.Open(MY_FILE, gdal.GA_ReadOnly) ds = None
With OGR, I found two ways to do that:
from osgeo import ogr ds = ogr.Open(MY_FILE) ds = None # outputs: # R6025 # - pure virtual function call # crashes the debugger ds.Destroy() # same
While it seems to work fine with both methods when I run the full script, it crashes my debugger when I run it in debug mode (PyCharm, in my case). In the console,
ds = None seems to work, while
ds.Destroy() crashes the whole console with the
Pure virtual function call output.
Is this specific to PyCharm or am I doing something essentially wrong?