Author chris.jerdonek
Recipients chris.jerdonek, gvanrossum, hynek, martin.panter, ned.deily, njs, vstinner, yselivanov
Date 2020-05-03.04:57:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1588481843.79.0.0984798695481.issue29587@roundup.psfhosted.org>
In-reply-to
Content
Okay, I was able to remove the NULL value check and get things working with a NULL exception value. I just posted a second follow-on PR that does this (which Guido approved - thanks, Guido!):
https://github.com/python/cpython/pull/19877

I wanted to tell you what I found since it raises some questions.

To remove that check I had to add the following new check prior to calling `_PyErr_ChainExceptions()` with the exception info, as a replacement:
`gen->gi_exc_state.exc_type != Py_None`
Without doing this, code like the following would crash e.g. on Fedora 32 (this is the crash that was happening in the first version of my PR, reduced down):

    def g():
        try:
            raise KeyError
        except KeyError:
            pass

        try:
            yield
        except Exception:
            # Crash happens here e.g. on Fedora 32 but not Mac.
            raise RuntimeError

    gen = g()
    gen.send(None)
    gen.throw(ValueError)

This raises two questions for me:

First, I thought exc_type could only ever be NULL or an exception class. So I'm wondering if this points to a problem elsewhere in the code base.

Second, I don't know why it would crash on Fedora but not Mac. (On Mac, you instead see the following exception chained beneath the ValueError:
> TypeError: print_exception(): Exception expected for value, NoneType found )
History
Date User Action Args
2020-05-03 04:57:23chris.jerdoneksetrecipients: + chris.jerdonek, gvanrossum, vstinner, ned.deily, njs, hynek, martin.panter, yselivanov
2020-05-03 04:57:23chris.jerdoneksetmessageid: <1588481843.79.0.0984798695481.issue29587@roundup.psfhosted.org>
2020-05-03 04:57:23chris.jerdoneklinkissue29587 messages
2020-05-03 04:57:23chris.jerdonekcreate