Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#28569 closed Bug (fixed)

Broken error handling when fetching GDAL datasource layer by string.

Reported by: Nick Pope Owned by: Nick Pope
Component: GIS Version: dev
Severity: Normal Keywords: gdal datasource layer indexerror
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When working on ticket #28558, I noticed that the error handling was broken in the case of accessing a layer on a datasource by string name.

The get_layer_by_name function raised GDALException instead of returning None in the case of an invalid string name as is expected by DataSource.__getitem__.

Looking at all of the other get_*_by_name functions, they pass errcheck=False to avoid an exception being raised.

It seems as though this has been broken from the initial implementation.

Change History (3)

comment:1 by Nick Pope, 7 years ago

Has patch: set
Owner: changed from nobody to Nick Pope
Status: newassigned

comment:2 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: assignedclosed

In 0d9e1163:

Fixed #28569 -- Corrected get_layer_by_name prototype to skip error checking.

All other get_*_by_name functions have errcheck=False. This makes it
return None for an invalid name instead of raising a GDALException.

comment:3 by Sergey Fedoseev <fedoseev.sergey@…>, 7 years ago

In c2ecef8:

Refs #28569 -- Fixed gis_tests.inspectapp.tests.OGRInspectTest.test_time_field.

Note: See TracTickets for help on using tickets.
Back to Top