Worked on ticket 18003, used re-raise instead of raise. Patched a global name issue that failed in Python 3