Catch exception if open() fails as well.

Drop support for python 2.4.