[gdal-dev] Possible SWIG Python bug
Leonardo Piga
leonardo.piga at gmail.com
Sat Dec 19 09:32:23 EST 2009
I'm working on creating an autotest for OGR GTM driver, I just started
the work and I faced a little problem with the script run_all.py.
I've already solved the problem, however, since I'm not a Python
expert, I'm reporting the problem that I had. If it is not a bug,
please excuse me.
I've checked out and installed gdal from source. I've checked out
autotest scripts, too.
When I ran run_all.py I got the following message:
Traceback (most recent call last):
File "run_all.py", line 30, in <module>
import gdaltest
File "pymod/gdaltest.py", line 35, in <module>
from osgeo import gdal
File "/usr/local/lib/python2.6/dist-packages/osgeo/__init__.py",
line 21, in <module>
_gdal = swig_import_helper()
File "/usr/local/lib/python2.6/dist-packages/osgeo/__init__.py",
line 20, in swig_import_helper
return _mod
UnboundLocalError: local variable '_mod' referenced before assignment
I took a look at the file
/usr/local/lib/python2.6/dist-packages/osgeo/__init__.py and I saw
that I was having an exception, but the error message was not giving
me any hint. I think there is a bug in __init__.py code, because _mod
is being used without being defined when the exception is raised.
Take a look at these lines:
try:
_mod = imp.load_module('_gdal', fp, pathname, description)
finally:
fp.close()
return _mod
Is it really a bug? Is it possible to define _mod before the try and
finally block?
In time, I solved the problem by making LD_LIBRARY_PATH point to
/user/local/lib. So I'm not having the exception anymore and the
problem was solved.
Thanks a lot
--
Leonardo de Paula Rosa Piga
http://lampiao.lsc.ic.unicamp.br/~piga
More information about the gdal-dev
mailing list