[Python-Dev] PyErr_ Fetch | Restore & friends
Ethan Furman
ethan at stoneleaf.us
Sat Mar 29 22:05:36 CET 2014
On 03/29/2014 01:47 PM, Nick Coghlan wrote:
> On 30 March 2014 03:05, Ethan Furman <ethan at stoneleaf.us> wrote:
>>
>> This bit of code won't even finish compiling. I am not sure if my
>> understanding of references (and how these functions create/consume them) or
>> my understanding of when and where to call PyErr_Fetch|Restore or
>> PyException_SetContext is at fault, but I would greatly appreciate somebody
>> correcting my understanding. :)
>
> I had to figure this out for the codec exception chaining in Python
> 3.4, and the main piece that appears to be missing from your code is
> an appropriate call to PyErr_NormalizeException(). (The interpreter
> tries to avoid actually instantiating exceptions if it can, with the
> consequence that explicit normalisation is often needed before
> non-trivial operations on the current exception)h
One of the many gyrations I tried before asking for help involved calling PyErr_NormalizeException, but it didn't seem
to solve the problem so I removed it before posting the minimum that I thought should work.
> This is the code that does the heavy lifting for the codec exception
> chaining in Python 3.4:
>
> http://hg.python.org/cpython/file/36492f927a40/Objects/exceptions.c#l2644
> http://hg.python.org/cpython/file/36492f927a40/Objects/exceptions.c#l2764
Thanks, I'll check those out.
--
~Ethan~
More information about the Python-Dev
mailing list