Ticket #2926 (closed defect: fixed)
Python constructors don't fail properly
| Reported by: | manderson | Owned by: | hobu |
|---|---|---|---|
| Priority: | low | Milestone: | 1.7.0 |
| Component: | PythonBindings | Version: | unspecified |
| Severity: | minor | Keywords: | |
| Cc: | warmerdam, tamas, rouault |
Description
The first time I tried out the Python bindings I used the following:
from osgeo import ogr
from osgeo.gdalconst import *
shpdrv = ogr.GetDriverByName?("ESRI Shapefile")
dsloc = shpdrv.CreateDataSource?("outputDir")
# etc etc... Until I was about to add geometry
tstGeo = ogr.Geometry()
tstGeo.AddPoint?(0, 1, 1)
After the AddPoint? call Python failed with a TypeError? in ogr.py: (snip) in AddPoint?
return _ogr.Geometry_AddPoint(*args, **kwargs)
TypeError?: in method 'Geometry_AddPoint', argument 1 of type 'OGRGeometryShadow *'
I realize this is because the Geometry object is not being created in the intended way (I got excited...) but would it be worth it to add docstrings to the init methods in the Python bindings (in general and specifically to ogr.Geometry.init) to provide a gentle introduction for GDAL/Python new people? Perhaps throw a less vague error when this happens?
This is happening using gdal-1.6 and Python 2.6.1, both compiled with GCC 3.4.4 running under Cygwin.
