[issue11441] compile() raises SystemError if called from except clause

Daniel Urban report at bugs.python.org
Thu Mar 10 18:13:56 CET 2011


Daniel Urban <urban.dani+py at gmail.com> added the comment:

So, I see four possible solutions:

1. If we get a tuple, create the new tuple, normalize the exception, and store it.  If we get a SyntaxError instance, use its args, create the new tuple, normalize, and store.  (In this case a SyntaxError instance will be created twice.)

2. If we get a tuple, create the new tuple and store it without normalization.  If we get a SyntaxError instance use its args to create the new tuple and store it without normalization.  (I think, that later it's still possible that a new SynaxError will be created, but we don't create it here.)

3. If we get a tuple, create the new tuple, and store it without normalization.  If we get a SyntaxError, take its args, create the new tuple, and call SyntaxError.__init__ with it. I think this will set all fields properly.

4. Like 3., but if we got a tuple, store the new tuple with normalization.

My patch currently does 1. 
My patch, without the PyErr_NormalizeException() call would be 2.
I think maybe 3. would be the best solution, or 4., if normalization is desired in all cases.

I can write a new patch, if the experts tell me what is the best solution from the four (or some other I didn't think of).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11441>
_______________________________________


More information about the Python-bugs-list mailing list