Opened 12 years ago

Closed 12 years ago

#18640 closed Bug (fixed)

django.contrib.gis.gdal.DataSource fields give gibberish or segfault when accessed directly

Reported by: YenTheFirst Owned by: jbronn
Component: GIS Version: 1.4
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

if you hold a feature in a variable, and access a field, it will give the correct value.

however, if you access a feature's field by layer[<index>][<field_name>], it gives gibberish, or a segfault.

this might be related to https://code.djangoproject.com/ticket/9448. however, given that the ticket was closed, it might be a different issue.

script to reproduce issue:

import os
import django.contrib.gis
from django.contrib.gis.gdal import DataSource
 
GIS_PATH = os.path.dirname(django.contrib.gis.__file__)
CITIES_PATH = os.path.join(GIS_PATH, 'tests/data/cities/cities.shp')
 
ds = DataSource(CITIES_PATH)
layer = ds[0]
feature = layer[0]
field = feature['Name']
 
print "this is valid: %r (%r)" % (field.value, list(field.value))
 
field = layer[0]['Name']
 
print "but this isn't: %r (%r)" % (field.value, list(field.value))

in python, results in segfault.
in ipython:
this is valid: 'Pueblo' (['P', 'u', 'e', 'b', 'l', 'o'])
but this isn't: ':\xd5\xe2=\xb1\xb4\xb9\xb4Q' ([':', '\xd5', '\xe2', '=', '\xb1', '\xb4', '\xb9', '\xb4', 'Q'])

saved as script, results in:
this is valid: 'Pueblo' (['P', 'u', 'e', 'b', 'l', 'o'])
but this isn't: ([])

this is on an ubuntu 11.04, with django 1.4, and gdal 1.7

Attachments (2)

18640-1.diff (4.5 KB ) - added by Claude Paroz 12 years ago.
Add parent references to GDAL Feature/Field
18640-2.diff (7.4 KB ) - added by jbronn 12 years ago.

Download all attachments as: .zip

Change History (6)

by Claude Paroz, 12 years ago

Attachment: 18640-1.diff added

Add parent references to GDAL Feature/Field

comment:1 by Claude Paroz, 12 years ago

Component: UncategorizedGIS
Has patch: set
Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

Confirmed. It appears that it is the same type of issue as in #9448. At least, adding references to parent objects seems to solve the problem.

by jbronn, 12 years ago

Attachment: 18640-2.diff added

comment:2 by jbronn, 12 years ago

Owner: changed from nobody to jbronn
Status: newassigned

Yeah this is a problem. I've updated the implementation, but will need to review more when I get home from the sprints.

comment:3 by jbronn, 12 years ago

Severity: NormalRelease blocker

comment:4 by Claude Paroz <claude@…>, 12 years ago

Resolution: fixed
Status: assignedclosed

In cb9f71dd99f0e524c871830b248cf28fcacd5753:

Fixed #18640 -- Allowed access to GDAL Feature without Datasource

Thanks Justin Bronn for improving my initial patch.

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