[Django] #27960: ds = DataSource('/path/to/your/cities.shp') fails on first try (GDALException Unknown error code: "198770787"), but works on second

78 views
Skip to first unread message

Django

unread,
Mar 19, 2017, 11:24:33 AM3/19/17
to django-...@googlegroups.com
#27960: ds = DataSource('/path/to/your/cities.shp') fails on first try
(GDALException Unknown error code: "198770787"), but works on second
-------------------------------------+-------------------------------------
Reporter: Etiënne | Owner: nobody
Thomassen |
Type: Bug | Status: new
Component: GIS | Version: 1.10
Severity: Normal | Keywords: DataSource, GIS
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I can not create a DataSource from a gpx file. It returns GDALException
Unknown error code: "198770787" with the error code number seemingly
random. However on the second try it works. And it does not even need to
be the same file.


{{{
Python 3.6.0 (default, Dec 24 2016, 08:01:42)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from django.contrib.gis.gdal import DataSource
>>> ds = DataSource('Bleswerk dec16.gpx')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/etienne/.virtualenvs/bosbot3/lib/python3.6/site-
packages/django/contrib/gis/gdal/datasource.py", line 64, in __init__
Driver.ensure_registered()
File "/Users/etienne/.virtualenvs/bosbot3/lib/python3.6/site-
packages/django/contrib/gis/gdal/driver.py", line 83, in ensure_registered
rcapi.register_all()
File "/Users/etienne/.virtualenvs/bosbot3/lib/python3.6/site-
packages/django/contrib/gis/gdal/prototypes/errcheck.py", line 119, in
check_errcode
check_err(result, cpl=cpl)
File "/Users/etienne/.virtualenvs/bosbot3/lib/python3.6/site-
packages/django/contrib/gis/gdal/error.py", line 74, in check_err
raise GDALException('Unknown error code: "%s"' % code)
django.contrib.gis.gdal.error.GDALException: Unknown error code:
"-1935278031"
>>> ds = DataSource('20140525_170950_gpx.gpx')
>>> ds.layer_count
5
}}}

This post on StackOverflow pointed me in this direction:
http://stackoverflow.com/questions/41775536/datasource-gdalexception-
unknown-error-code-474873798

Strangely, I can now get it to work doing this in my app:

{{{
try:
datasource = DataSource(target_path)
except:
datasource = DataSource(target_path)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27960>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 19, 2017, 11:36:05 AM3/19/17
to django-...@googlegroups.com
#27960: ds = DataSource('/path/to/your/cities.shp') fails on first try
(GDALException Unknown error code: "198770787"), but works on second
-----------------------------------+--------------------------------------
Reporter: Etiënne Thomassen | Owner: nobody

Type: Bug | Status: new
Component: GIS | Version: 1.10
Severity: Normal | Resolution:
Keywords: DataSource, GIS | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Description changed by Etiënne Thomassen:

Old description:

New description:

Btw this part of my app stopped working migrating from Django 1.8 and
Python 2.7 to Django 1.9 and Python 3.6. Now on Django 1.10 and Python 3.6

--

--
Ticket URL: <https://code.djangoproject.com/ticket/27960#comment:1>

Django

unread,
Mar 19, 2017, 11:41:33 AM3/19/17
to django-...@googlegroups.com
#27960: ds = DataSource('/path/to/your/cities.shp') fails on first try
(GDALException Unknown error code: "198770787"), but works on second
-----------------------------------+--------------------------------------
Reporter: Etiënne Thomassen | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 1.10
Severity: Normal | Resolution:
Keywords: DataSource, GIS | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Description changed by Etiënne Thomassen:

Old description:

> I can not create a DataSource from a gpx file. It returns GDALException

> Btw this part of my app stopped working migrating from Django 1.8 and
> Python 2.7 to Django 1.9 and Python 3.6. Now on Django 1.10 and Python
> 3.6

New description:

I can not create a DataSource from a gpx file. It returns GDALException
Unknown error code: "198770787" with the error code number seemingly
random. However on the second try it works. And it does not even need to
be the same file.


{{{
Python 3.6.0 (default, Dec 24 2016, 08:01:42)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from django.contrib.gis.gdal import DataSource

>>> ds = DataSource('gpxfile1.gpx')


Traceback (most recent call last):
File "<stdin>", line 1, in <module>

File "/Users/etienne/.virtualenvs/venv1/lib/python3.6/site-


packages/django/contrib/gis/gdal/datasource.py", line 64, in __init__
Driver.ensure_registered()

File "/Users/etienne/.virtualenvs/venv1/lib/python3.6/site-


packages/django/contrib/gis/gdal/driver.py", line 83, in ensure_registered
rcapi.register_all()

File "/Users/etienne/.virtualenvs/venv1/lib/python3.6/site-


packages/django/contrib/gis/gdal/prototypes/errcheck.py", line 119, in
check_errcode
check_err(result, cpl=cpl)

File "/Users/etienne/.virtualenvs/venv1/lib/python3.6/site-


packages/django/contrib/gis/gdal/error.py", line 74, in check_err
raise GDALException('Unknown error code: "%s"' % code)
django.contrib.gis.gdal.error.GDALException: Unknown error code:
"-1935278031"

>>> ds = DataSource('gpxfile2.gpx')
>>> ds.layer_count
5
}}}

This post on StackOverflow pointed me in this direction:
http://stackoverflow.com/questions/41775536/datasource-gdalexception-
unknown-error-code-474873798

Strangely, I can now get it to work doing this in my app:

{{{
try:
datasource = DataSource(target_path)
except:
datasource = DataSource(target_path)
}}}

Btw this part of my app stopped working migrating from Django 1.8 and


Python 2.7 to Django 1.9 and Python 3.6. Now on Django 1.10 and Python 3.6

--

--
Ticket URL: <https://code.djangoproject.com/ticket/27960#comment:2>

Django

unread,
Mar 20, 2017, 1:19:53 PM3/20/17
to django-...@googlegroups.com
#27960: ds = DataSource('/path/to/your/cities.shp') fails on first try
(GDALException Unknown error code: "198770787"), but works on second
-----------------------------------+--------------------------------------
Reporter: Etiënne Thomassen | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 1.10
Severity: Normal | Resolution:
Keywords: DataSource, GIS | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by Tim Graham):

Can you provide the gpx file in question? It would be helpful if you could
[https://docs.djangoproject.com/en/dev/internals/contributing/triaging-
tickets/#bisecting-a-regression bisect] to find the Django commit where
the behavior changed.

--
Ticket URL: <https://code.djangoproject.com/ticket/27960#comment:3>

Django

unread,
Mar 21, 2017, 3:55:37 AM3/21/17
to django-...@googlegroups.com
#27960: ds = DataSource('/path/to/your/cities.shp') fails on first try
(GDALException Unknown error code: "198770787"), but works on second
-----------------------------------+--------------------------------------
Reporter: Etiënne Thomassen | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 1.10
Severity: Normal | Resolution:
Keywords: DataSource, GIS | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by Etiënne Thomassen):

* Attachment "gpxfile.gpx" added.

Example gpx file (waypoints and tracks do not represent anything in real
world). But any valid gpx file triggers the error

Django

unread,
Mar 21, 2017, 3:58:57 AM3/21/17
to django-...@googlegroups.com
#27960: ds = DataSource('/path/to/your/cities.shp') fails on first try
(GDALException Unknown error code: "198770787"), but works on second
-----------------------------------+--------------------------------------
Reporter: Etiënne Thomassen | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 1.10
Severity: Normal | Resolution:
Keywords: DataSource, GIS | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by Etiënne Thomassen):

Replying to [comment:3 Tim Graham]:


> Can you provide the gpx file in question? It would be helpful if you

could [https://docs.djangoproject.com/en/dev/internals/contributing
/triaging-tickets/#bisecting-a-regression bisect] to find the Django


commit where the behavior changed.

Added an example gpx file that triggers the error. But any valid gpx file
does so. Will look into bisect.

--
Ticket URL: <https://code.djangoproject.com/ticket/27960#comment:4>

Django

unread,
Mar 21, 2017, 6:57:26 AM3/21/17
to django-...@googlegroups.com
#27960: ds = DataSource('/path/to/your/cities.shp') fails on first try
(GDALException Unknown error code: "198770787"), but works on second
-----------------------------------+--------------------------------------
Reporter: Etiënne Thomassen | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 1.10
Severity: Normal | Resolution:
Keywords: DataSource, GIS | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by Sergey Fedoseev):

Replying to [ticket:27960 Etiënne Thomassen]:

I can't reproduce it. I tried both on master an on 1.10.

Could you try to replace
{{{
register_all = void_output(std_call('GDALAllRegister'), [])
}}}
with
{{{
register_all = void_output(std_call('GDALAllRegister'), [],
errcheck=False)
}}}
in `django/contrib/gis/gdal/prototypes/raster.py` and say if it works for
you?

--
Ticket URL: <https://code.djangoproject.com/ticket/27960#comment:5>

Django

unread,
Mar 21, 2017, 7:00:23 AM3/21/17
to django-...@googlegroups.com
#27960: ds = DataSource('/path/to/your/cities.shp') fails on first try
(GDALException Unknown error code: "198770787"), but works on second
-----------------------------------+--------------------------------------
Reporter: Etiënne Thomassen | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 1.10
Severity: Normal | Resolution:
Keywords: DataSource, GIS | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by Claude Paroz):

I think knowing the GDAL version on tested systems might be a key here.

--
Ticket URL: <https://code.djangoproject.com/ticket/27960#comment:6>

Django

unread,
Mar 21, 2017, 8:37:23 AM3/21/17
to django-...@googlegroups.com
#27960: ds = DataSource('/path/to/your/cities.shp') fails on first try
(GDALException Unknown error code: "198770787"), but works on second
-----------------------------------+--------------------------------------
Reporter: Etiënne Thomassen | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 1.10
Severity: Normal | Resolution:
Keywords: DataSource, GIS | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by Etiënne Thomassen):

Replying to [comment:6 Claude Paroz]:


> I think knowing the GDAL version on tested systems might be a key here.

I am using GDAL 2.1.2, released 2016/10/24 (with Django 1.10 and Python
3.6)

Previous version was 1.10.1 (with Django 1.8 and Python 2.7)

--
Ticket URL: <https://code.djangoproject.com/ticket/27960#comment:7>

Django

unread,
Mar 21, 2017, 10:23:59 AM3/21/17
to django-...@googlegroups.com
#27960: ds = DataSource('/path/to/your/cities.shp') fails on first try
(GDALException Unknown error code: "198770787"), but works on second
-----------------------------------+--------------------------------------
Reporter: Etiënne Thomassen | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 1.10
Severity: Normal | Resolution:
Keywords: DataSource, GIS | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by Claude Paroz):

I cannot reproduce but suspect the fix proposed by Sergei should work for
you. Please try and report.

--
Ticket URL: <https://code.djangoproject.com/ticket/27960#comment:8>

Django

unread,
Mar 21, 2017, 10:50:02 AM3/21/17
to django-...@googlegroups.com
#27960: ds = DataSource('/path/to/your/cities.shp') fails on first try
(GDALException Unknown error code: "198770787"), but works on second
-----------------------------------+--------------------------------------
Reporter: Etiënne Thomassen | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 1.10
Severity: Normal | Resolution:
Keywords: DataSource, GIS | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by Etiënne Thomassen):

Replying to [comment:5 Sergey Fedoseev]:


> Replying to [ticket:27960 Etiënne Thomassen]:
>

> I can't reproduce it. I tried both on master and on 1.10.


>
> Could you try to replace
> {{{
> register_all = void_output(std_call('GDALAllRegister'), [])
> }}}
> with
> {{{
> register_all = void_output(std_call('GDALAllRegister'), [],
errcheck=False)
> }}}
> in `django/contrib/gis/gdal/prototypes/raster.py` and say if it works
for you?

This works!

--
Ticket URL: <https://code.djangoproject.com/ticket/27960#comment:9>

Django

unread,
Mar 21, 2017, 10:57:14 AM3/21/17
to django-...@googlegroups.com
#27960: ds = DataSource('/path/to/your/cities.shp') fails on first try
(GDALException Unknown error code: "198770787"), but works on second
-----------------------------------+--------------------------------------
Reporter: Etiënne Thomassen | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 1.10
Severity: Normal | Resolution:
Keywords: DataSource, GIS | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by Etiënne Thomassen):

Replying to [comment:8 Claude Paroz]:


> I cannot reproduce but suspect the fix proposed by Sergei should work
for you. Please try and report.

Thanks, I somehow missed Sergey's comment. He is right.

--
Ticket URL: <https://code.djangoproject.com/ticket/27960#comment:10>

Django

unread,
Mar 21, 2017, 10:58:09 AM3/21/17
to django-...@googlegroups.com
#27960: ds = DataSource('/path/to/your/cities.shp') fails on first try
(GDALException Unknown error code: "198770787"), but works on second
-----------------------------------+--------------------------------------
Reporter: Etiënne Thomassen | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 1.10
Severity: Normal | Resolution:
Keywords: DataSource, GIS | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by Sergey Fedoseev):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/8226 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/27960#comment:11>

Django

unread,
Mar 21, 2017, 11:38:46 AM3/21/17
to django-...@googlegroups.com
#27960: ds = DataSource('/path/to/your/cities.shp') fails on first try
(GDALException Unknown error code: "198770787"), but works on second
-------------------------------------+-------------------------------------
Reporter: Etiënne Thomassen | Owner: nobody

Type: Bug | Status: new
Component: GIS | Version: 1.10
Severity: Normal | Resolution:
Keywords: DataSource, GIS | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

* stage: Unreviewed => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/27960#comment:12>

Django

unread,
Mar 21, 2017, 11:45:20 AM3/21/17
to django-...@googlegroups.com
#27960: ds = DataSource('/path/to/your/cities.shp') fails on first try
(GDALException Unknown error code: "198770787"), but works on second
-------------------------------------+-------------------------------------
Reporter: Etiënne Thomassen | Owner: nobody
Type: Bug | Status: closed
Component: GIS | Version: 1.10
Severity: Normal | Resolution: fixed

Keywords: DataSource, GIS | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"7063a85579f40585f2601ba6e6887b0982e7ce43" 7063a855]:
{{{
#!CommitTicketReference repository=""
revision="7063a85579f40585f2601ba6e6887b0982e7ce43"
Fixed #27960 -- Set errcheck=False for GDALAllRegister to prevent crash.

GDALAllRegister returns void so errcheck is not needed.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27960#comment:13>

Django

unread,
Mar 21, 2017, 11:45:57 AM3/21/17
to django-...@googlegroups.com
#27960: ds = DataSource('/path/to/your/cities.shp') fails on first try
(GDALException Unknown error code: "198770787"), but works on second
-------------------------------------+-------------------------------------
Reporter: Etiënne Thomassen | Owner: nobody
Type: Bug | Status: closed
Component: GIS | Version: 1.10

Severity: Normal | Resolution: fixed
Keywords: DataSource, GIS | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"a937785e2a6eb3d9b8804c3a02ba5d0126482f57" a937785e]:
{{{
#!CommitTicketReference repository=""
revision="a937785e2a6eb3d9b8804c3a02ba5d0126482f57"
[1.11.x] Fixed #27960 -- Set errcheck=False for GDALAllRegister to prevent
crash.

GDALAllRegister returns void so errcheck is not needed.

Backport of 7063a85579f40585f2601ba6e6887b0982e7ce43 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27960#comment:14>

Reply all
Reply to author
Forward
0 new messages