summaryrefslogtreecommitdiff
path: root/Include
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2001-01-15 20:40:19 +0000
committerBarry Warsaw <barry@python.org>2001-01-15 20:40:19 +0000
commite5b69bb9c20778f9f310e3f1765a635619945102 (patch)
treea71c550f50f5062d9e947863ea4efa7a1229f4dc /Include
parentb0ce12c6d7bfeb2ac606bf942e776a8278085aa8 (diff)
downloadcpython-e5b69bb9c20778f9f310e3f1765a635619945102.tar.gz
Committing PEP 232, function attribute feature, approved by Guido.
Closes SF patch #103123. funcobject.h: PyFunctionObject: add the func_dict slot. funcobject.c: PyFunction_New(): Initialize the func_dict slot to NULL. func_getattr(): Rename to func_getattro() and change the signature. It's more efficient to use attro methods and dig the C string out than it is to re-convert a C string to a PyString. Also, add support for getting the __dict__ (a.k.a. func_dict) attribute, and for getting an arbitrary function attribute. func_setattr(): Rename to func_setattro() and change the signature for the same reason. Also add support for setting __dict__ (a.k.a. func_dict) and any arbitrary function attribute. func_dealloc(): Be sure to DECREF the func_dict slot. func_traverse(): Be sure to traverse func_dict too. PyFunction_Type: make the necessary func_?etattro() changes. classobject.c: instancemethod_memberlist: Add __dict__ instancemethod_setattro(): New method to set arbitrary attributes on methods (really the underlying im_func). Raise TypeError when the instance is bound or when you're trying to set one of the reserved im_* attributes. instancemethod_getattr(): Renamed to instancemethod_getattro() since that's what it really is. Also, added support fo getting arbitrary attributes through the im_func. PyMethod_Type: Do the ?etattr{,o} dance.
Diffstat (limited to 'Include')
-rw-r--r--Include/funcobject.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/Include/funcobject.h b/Include/funcobject.h
index 6ba1e0925e..35ccf43ed2 100644
--- a/Include/funcobject.h
+++ b/Include/funcobject.h
@@ -14,6 +14,7 @@ typedef struct {
PyObject *func_defaults;
PyObject *func_doc;
PyObject *func_name;
+ PyObject *func_dict;
} PyFunctionObject;
extern DL_IMPORT(PyTypeObject) PyFunction_Type;