[issue46903] Crash when setting attribute with string subclass as the name (--with-pydebug)

Ronald Oussoren report at bugs.python.org
Wed Mar 2 16:30:36 EST 2022


New submission from Ronald Oussoren <ronaldoussoren at mac.com>:

The script below fails with an assertion error with python 3.11a5+ (current trunk) when build with --with-pydebug:

# BEGIN OF FILE
class String(str):
    __slots__ = ()

name = String("hello")

class Bag:
    pass

o = Bag()
setattr(o, name, 42)

# END OF FILE

Error output:

% /tmp/py311/bin/python3 -Xdev str.py                                                                                                                 (master)pyobjc-8
Assertion failed: (PyUnicode_CheckExact(name)), function _PyObject_StoreInstanceAttribute, file dictobject.c, line 5426.
Fatal Python error: Aborted

Current thread 0x0000000100a98580 (most recent call first):
  File "/Users/ronald/Projects/pyobjc-8/pyobjc-core/str.py", line 10 in <module>
zsh: abort      /tmp/py311/bin/python3 -Xdev str.py

----------
components: Interpreter Core
messages: 414386
nosy: ronaldoussoren
priority: normal
severity: normal
status: open
title: Crash when setting attribute with string subclass as the name (--with-pydebug)
type: crash
versions: Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46903>
_______________________________________


More information about the Python-bugs-list mailing list