Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#7094 closed defect (fixed)

Can't open MITAB with missing IND file in Python

Reported by: cdestigter Owned by: hobu
Priority: normal Milestone: 2.2.3
Component: PythonBindings Version: 2.2.2
Severity: normal Keywords:
Cc:

Description (last modified by cdestigter)

We have been provided a TAB which is admittedly slightly broken. It has no IND file, but the field listing in the TAB suggests it should (because some fields are indexed.)

ogrinfo happily reads the file with a warning, and QGIS is happy to read it somehow. However, opening the file via the Python bindings doesn't work:

>>> gdal.UseExceptions()

>>> gdal.GetUseExceptions()
1

>>> x = gdal.OpenEx('broken.tab', gdal.OF_VERBOSE_ERROR)
CPLError: Open() failed for broken.ind (rb)
CPLError: Failed to open index file broken.IND.
GDAL: GDALOpen(broken.tab, this=0x213a680) succeeds as MapInfo File.
GDAL: GDALClose(broken.tab, this=0x213a680)

>>> x is None
True

Note that not only did the open fail, but no exception was thrown, despite setting the right flags.

However, ogrinfo seems happy to read the file correctly:

$ ogrinfo -so -ro -al broken.tab
GNM: GNMRegisterAllInternal
GNM: RegisterGNMFile
GNM: RegisterGNMdatabase
CPLError: Open() failed for broken.ind (rb)
ERROR 3: Open() failed for broken.ind (rb)
CPLError: Failed to open index file broken.IND.
ERROR 4: Failed to open index file broken.IND.
GDAL: GDALOpen(broken.tab, this=0xec6bb0) succeeds as MapInfo File.
INFO: Open of `broken.tab'
      using driver `MapInfo File' successful.
OGR: GetLayerCount() = 1


Layer name: broken
Geometry: Point
Feature Count: 76
Extent: (-0.905866, 0.293315) - (0.100955, 0.907231)
Layer SRS WKT:
GEOGCS["unnamed",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563],
        TOWGS84[0,0,0,0,0,0,0]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433]]
FID: Integer (0.0)
GDAL: GDALClose(broken.tab, this=0xec6bb0)
GDAL: In GDALDestroy - unloading GDAL shared library.

This is with a slightly-custom GDAL 2.2.x.

Attachments (1)

broken.zip (1.9 KB ) - added by cdestigter 6 years ago.

Download all attachments as: .zip

Change History (6)

by cdestigter, 6 years ago

Attachment: broken.zip added

comment:1 by cdestigter, 6 years ago

Description: modified (diff)

comment:2 by Even Rouault, 6 years ago

In 40511:

Python bindings: make sure that errors in Open() related functions, that do not prevent dataset opening in C/C++, do not either prevent it in Python (refs #7094)

comment:3 by Even Rouault, 6 years ago

Resolution: fixed
Status: newclosed

In 40512:

MITAB: do not emit error if the .ind file is missing, just a debug message (fixes #7094)

comment:4 by Even Rouault, 6 years ago

In 40513:

MITAB: do not emit error if the .ind file is missing, just a debug message (fixes #7094)

comment:5 by Even Rouault, 6 years ago

Milestone: 2.2.3
Note: See TracTickets for help on using tickets.