Has anyone tried setting class attributes on a new-style class in C? The file sandbox/datetime/datetime.py has code that does this: class datetime(basetime): ... datetime.min = datetime(...) datetime.max = datetime(...) I can easily add descriptors in the C version so that min and max are defined on instances, but using PyObject_SetAttrString() using the new class: tmp = create_datetime(...); if (datetime_min == NULL) return; if (PyObject_SetAttrString((PyObject *) &PyDateTime_Type, "min", datetime_min) < 0) return; produces this exception: Traceback (most recent call last): File "test_cdatetime.py", line 9, in ? from _datetime import datetime, MINYEAR, MAXYEAR TypeError: can't set attributes of built-in/extension type 'datetime.datetime' (where _datetime is the C extension that implements the C version of the type). Any ideas? -Fred -- Fred L. Drake, Jr. <fdrake at acm.org> PythonLabs at Zope Corporation
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4