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.