[Python-Dev] Odd errors when catching ImportError
Paul Dubois
paul@pfdubois.com
Wed, 30 Jan 2002 09:39:45 -0800
Please excuse me if this is in the bug list; I looked through it but the
list is too long for old people.
I have been running into a number of odd errors caused by code like the
following. The behavior seems to be machine dependent.
fooflag = 0
try:
import foo
except ImportError:
fooflag = 1
I have had this result in a seg fault upon exit, and also when something
like this was in file xxx.py inside a package, and the __init__.py did
from xxx import fooflag
I've had it tell me xxx had no attribute fooflag. I added "print fooflag" at
the bottom of the file and it fixed it. That was on a DEC. On Linux it
worked.
I suppose I should be testing for the ability to import foo some other way
but I don't know what it is.