Message408201
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)
========================================= |
|
Date |
User |
Action |
Args |
2021-12-10 12:32:58 | vstinner | set | recipients:
+ vstinner, methane, eric.snow, serhiy.storchaka, ndjensen, corona10, erlendaasland |
2021-12-10 12:32:58 | vstinner | set | messageid: <1639139578.68.0.798803058491.issue46006@roundup.psfhosted.org> |
2021-12-10 12:32:58 | vstinner | link | issue46006 messages |
2021-12-10 12:32:58 | vstinner | create | |
|