Greg Couch <gr...@cgl.ucsf.edu> added the comment:

FYI, I was able to work around this and use an unmodified Python by
subtyping type and overriding the setattr method as shown below.  It's a
lot messier than patching Python.

static int
Mutable_SetAttr(PyObject *obj, PyObject *name, PyObject *value)
{
        // Can't just call PyObject_GenericSetAttr because
        // we need to able to update the __str__ slot as well.
        PyTypeObject *type = reinterpret_cast<PyTypeObject*>(obj);
        type->tp_flags |= Py_TPFLAGS_HEAPTYPE;
        int result = PyType_Type.tp_setattro(obj, name, value);
        type->tp_flags &= ~Py_TPFLAGS_HEAPTYPE;
        return result;
}

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

Reply via email to