Fixed incompatibility in raising exceptions on python 2.6+/3+