Make file module work on python 2.4, fix #9080

Python 2.4 do not support "except ... as ..." construct, so
revert back to the older syntax.
Merge pull request #9082 from mscherer/fix9080/file_not_working_py24

Make file module work on python 2.4, fix #9080