0

PyErr_Fetch doesn't always return a triplet where the second argument is a PyException so, to ease the parsing, you might want to use PyErr_NormalizeException to sort that part out (see the documentation)

What the documentation doesn't say, however, is how normalize exception treats the original results of PyErr_Fetch in terms of memory retention when it creates the new exception instance.

Can I assume that whatever PyErr_NormalizeException does to the pointers of PyErr_Fetch I can PyErr_Restore them and be "ok" as far as memory is concerned?

I would say that this is the case, but maybe I'm missing a detail and I need to "do something" to the original fetch results instead.

Thank you!

Rick77
  • 3,121
  • 25
  • 43
  • 1
    If you search https://github.com/python/cpython for `PyErr_NormalizeException` then it looks like your assumption matches how it's used internally. Definitely doesn't mean I'm confident of that answer though – DavidW Apr 28 '20 at 07:25
  • Thank you for your remark, @DavidW (I admit I should have looked at the sources myself: shame on me): it also checks out with the projected use of the object (normalize will _most likely_ give the ownership of the ``pvalue`` to the newly created exception, so everything will balance out :) ). Cheers! – Rick77 Apr 28 '20 at 07:28

0 Answers0