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 vstinner
Recipients corona10, eric.snow, erlendaasland, methane, ndjensen, serhiy.storchaka, vstinner
Date 2021-12-10.12:32:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1639139578.68.0.798803058491.issue46006@roundup.psfhosted.org>
In-reply-to
Content
I marked bpo-46034 as a duplicate: setting a class "__init__" attribute doesn't update properly its tp_init slot. update_slot() of Objects/typeobject.c only uses a fast pointer comparison since both strings are interned, but the test fails if the two strings are part of two different Python interpreters.

In bpo-46034 case, the problem is that the "slotdefs" array uses interned strings created in the main interpreter, whereas the update_slot() name parameter (Python string) was created in a sub-interpreter.

Reproducer:
=========================================
import _testcapi

code = r"""class Greeting():
    pass

def new_init(inst, name):
    inst.text = f"Hello, {name}\n"

Greeting.__init__ = new_init

Greeting("Miro")"""

_testcapi.run_in_subinterp(code)
=========================================
History
Date User Action Args
2021-12-10 12:32:58vstinnersetrecipients: + vstinner, methane, eric.snow, serhiy.storchaka, ndjensen, corona10, erlendaasland
2021-12-10 12:32:58vstinnersetmessageid: <1639139578.68.0.798803058491.issue46006@roundup.psfhosted.org>
2021-12-10 12:32:58vstinnerlinkissue46006 messages
2021-12-10 12:32:58vstinnercreate