summaryrefslogtreecommitdiffstats
path: root/Include/funcobject.h
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2003-01-31 18:33:18 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2003-01-31 18:33:18 (GMT)
commit4f0dcc9a9a4629607d4fff79912e8d0c86cd3914 (patch)
treebba33e033f6a51fec1c01a79a5f6e931f65e44f2 /Include/funcobject.h
parent8f24cdc0d5e30e2f924ed2e8a71400fa87a70983 (diff)
downloadcpython-4f0dcc9a9a4629607d4fff79912e8d0c86cd3914.zip
cpython-4f0dcc9a9a4629607d4fff79912e8d0c86cd3914.tar.gz
cpython-4f0dcc9a9a4629607d4fff79912e8d0c86cd3914.tar.bz2
Provide __module__ attributes for functions defined in C and Python.
__module__ is the string name of the module the function was defined in, just like __module__ of classes. In some cases, particularly for C functions, the __module__ may be None. Change PyCFunction_New() from a function to a macro, but keep an unused copy of the function around so that we don't change the binary API. Change pickle's save_global() to use whichmodule() if __module__ is None, but add the __module__ logic to whichmodule() since it might be used outside of pickle.
Diffstat (limited to 'Include/funcobject.h')
-rw-r--r--Include/funcobject.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/Include/funcobject.h b/Include/funcobject.h
index 7fee800..758c76d 100644
--- a/Include/funcobject.h
+++ b/Include/funcobject.h
@@ -17,6 +17,7 @@ typedef struct {
PyObject *func_name;
PyObject *func_dict;
PyObject *func_weakreflist;
+ PyObject *func_module;
} PyFunctionObject;
PyAPI_DATA(PyTypeObject) PyFunction_Type;
@@ -26,6 +27,7 @@ PyAPI_DATA(PyTypeObject) PyFunction_Type;
PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *);
PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *);
PyAPI_FUNC(PyObject *) PyFunction_GetGlobals(PyObject *);
+PyAPI_FUNC(PyObject *) PyFunction_GetModule(PyObject *);
PyAPI_FUNC(PyObject *) PyFunction_GetDefaults(PyObject *);
PyAPI_FUNC(int) PyFunction_SetDefaults(PyObject *, PyObject *);
PyAPI_FUNC(PyObject *) PyFunction_GetClosure(PyObject *);
@@ -37,6 +39,8 @@ PyAPI_FUNC(int) PyFunction_SetClosure(PyObject *, PyObject *);
(((PyFunctionObject *)func) -> func_code)
#define PyFunction_GET_GLOBALS(func) \
(((PyFunctionObject *)func) -> func_globals)
+#define PyFunction_GET_MODULE(func) \
+ (((PyFunctionObject *)func) -> func_module)
#define PyFunction_GET_DEFAULTS(func) \
(((PyFunctionObject *)func) -> func_defaults)
#define PyFunction_GET_CLOSURE(func) \