Issue 7161: raise of SyntaxError in codeop was ported incorrectly to Py3 (original) (raw)

The original lines in Lib/codeop.py under Python 2.6:

raise SyntaxError, err1

Those lines were ported to Python 3 as:

raise SyntaxError(err1)

Which is wrong because err1 is in both cases an instance of SyntaxError. Quote from the language reference: "If the first object is a class, it becomes the type of the exception. The second object is used to determine the exception value: If it is an instance of the class, the instance becomes the exception value." Therefore, the correct translation of that code is: "raise err1".

The attached patch fixes the issue.