Opened 15 years ago
Closed 15 years ago
#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, Even 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.
Change History (3)
comment:1 by , 15 years ago
Cc: | added |
---|---|
Component: | default → PythonBindings |
Owner: | changed from | to
comment:2 by , 15 years ago
Cc: | added |
---|
comment:3 by , 15 years ago
Milestone: | → 1.7.0 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
I have attempted to fix this with r16720. Use ogr.UseExceptions() when you want this to actually throw an exception, otherwise, an error will be printed to stdout.