This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pablogsal
Recipients Mark.Shannon, christian.heimes, jdemeyer, lukasz.langa, pablogsal, petr.viktorin, pitrou, vstinner
Date 2019-09-02.13:15:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1567430112.71.0.49399379208.issue38006@roundup.psfhosted.org>
In-reply-to
Content
In https://bugs.python.org/issue33418 I proposed reverting tp_clear on function objects.

>What should be done when a function with func_code=NULL is called?

We can set the error indicator at least. Although I agree that it seems suboptimal. At least I think we should add an assertion to check that the function called is valid so we can identify this situation easier.

What downsides do we see raising an exception?

Notice that this can happen without involving weak references. For example:

You have object A and B. A is a function. The destructor of B calls A. A and B are in a cycle. When calling tp_clear on A the refs of B reaches 0, trying to call A and .... Boom!

Either we remove tp_clear or somehow we have to protect all callers of the function. Technically, any field cleared from tp_cleared leaves the function in an inconsistent state
History
Date User Action Args
2019-09-02 13:15:12pablogsalsetrecipients: + pablogsal, pitrou, vstinner, christian.heimes, petr.viktorin, lukasz.langa, Mark.Shannon, jdemeyer
2019-09-02 13:15:12pablogsalsetmessageid: <1567430112.71.0.49399379208.issue38006@roundup.psfhosted.org>
2019-09-02 13:15:12pablogsallinkissue38006 messages
2019-09-02 13:15:12pablogsalcreate