fixup_shp_columnnames silently fails with windows-1258 encoding #6394
Labels
minor
A low priority issue which might affect only some users and /or not the main functionality
Milestone
Expected Behavior
fixup_shp_columnnames()
renames shapefile column names containing windows-1258 characters.geonode.tests.integration.GeoNodeMapTest.test_layer_zip_upload_non_utf8
passes on the premise that the column names have been altered.Actual Behavior
Travis CI (GDAL 1.11)
An exception is thrown when executing
inLayerDefn.GetFieldDefn(i).GetName()
on line 1158Ubuntu 18.04 (GDAL 2.2.x)
The call to
inLayerDefn.GetFieldDefn(i).GetName()
succeeds and the function proceeds to the next block but the call toinDataSource.ExecuteSQL(qry)
on line 1203 causes a segmentation fault and no further tests are run.Ubuntu 18.04 w/ Ubuntu GIS PPA (GDAL 2.4.x)
The call to
inLayerDefn.GetFieldDefn(i).GetName()
succeeds and the function proceeds to the next block but the call toinDataSource.ExecuteSQL(qry)
on line 1203 causes aTypeError
which readsDiagnosis
inLayerDefn.GetFieldDefn(i).GetName()
is contained within atry
/except
block and, on exception thrown, the function returns the tuple(True, None, None)
. The test passes despite not having renamed any column names.ch.decode("utf-8", "surrogateescape")
on line 1173 always throws an exception asch
is a Pythonstr
type, not abytes
object. Theexcept
block is always executed because of this sohas_ch
isTrue
and the loop exits after the first iteration.TypeError
is caught but rethrown so there is no return value and the test fails.Proposed Fix
I have devised a form of fix to get my GNIP-75 PR running under Travis CI, as this involves an upgrade to
bionic
and therefore GDAL 2.4.x. However, the fix is still relevant for any installation methods that use GDAL 2.4.x.See 86a7214#diff-aadb2492556667858a9abd91a23ef330R1170
This can be restored to identical functionality as Travis CI by returning the same tuple in an
except TypeError:
block. See 86a7214#diff-aadb2492556667858a9abd91a23ef330R1196Currently, I do not have a solution for this underlying problem. Proposals welcome here.
Steps to Reproduce the Problem
docker-compose
orpaver
on themaster
branch../manage.py test geonode.tests.integration.GeoNodeMapTest.test_layer_zip_upload_non_utf8
locally or within thedjango4geonode
Docker containergdal-config --version
to fetch version)Alternatively, execute these calls on the
ming_female_1.shp
shapefile (one from the test) within a Docker container so that you can vary the GDAL version.Specifications
master
The text was updated successfully, but these errors were encountered: