Raise the expected exception for python 2.5

I don't know much about python but the current code looks wrong :)
Merge branch 'pterjan/patch-1' into 3.0