replace "ex = sys.exc_info()[1]" with "as ex" #38