New submission from Matthias Braun <matthi...@fb.com>:

This is about an extension type created via `PyType_FromSpec` that overrides 
`tp_setattro` (minimal example attached). In this case cpython does not let me 
grab and use the `__setattr__` function "manually". Example:

```
>>> import demo
>>> mytype_setattr = demo.MyType.__setattr__
>>> i = demo.MyType()
>>> mytype_setattr(i, "foo", "bar")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can't apply this __setattr__ to object object
```

I suspect this is related to the loop at the beginning of typeobject.c / 
hackcheck() that skips over types with Py_TPFLAGS_HEAPOBJECT. (Though removing 
the loop breaks things like the enum module).

----------
components: C API
files: demomodule.zip
messages: 364123
nosy: Matthias Braun
priority: normal
severity: normal
status: open
title: Using typename.__setattr__ in extension type with Py_TPFLAGS_HEAPTYPE is 
broken (hackcheck too eager?)
versions: Python 3.7
Added file: https://bugs.python.org/file48974/demomodule.zip

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39960>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to