STINNER Victor <vstin...@python.org> added the comment:
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) ========================================= ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue46006> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com