[Python-checkins] python/dist/src/Include funcobject.h,2.25,2.26 methodobject.h,2.25,2.26
jhylton@users.sourceforge.net
jhylton@users.sourceforge.net
Fri, 31 Jan 2003 10:33:49 -0800
Update of /cvsroot/python/python/dist/src/Include
In directory sc8-pr-cvs1:/tmp/cvs-serv18557/Include
Modified Files:
funcobject.h methodobject.h
Log Message:
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.
Index: funcobject.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/funcobject.h,v
retrieving revision 2.25
retrieving revision 2.26
diff -C2 -d -r2.25 -r2.26
*** funcobject.h 12 Aug 2002 07:21:56 -0000 2.25
--- funcobject.h 31 Jan 2003 18:33:15 -0000 2.26
***************
*** 18,21 ****
--- 18,22 ----
PyObject *func_dict;
PyObject *func_weakreflist;
+ PyObject *func_module;
} PyFunctionObject;
***************
*** 27,30 ****
--- 28,32 ----
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 *);
***************
*** 38,41 ****
--- 40,45 ----
#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)
Index: methodobject.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/methodobject.h,v
retrieving revision 2.25
retrieving revision 2.26
diff -C2 -d -r2.25 -r2.26
*** methodobject.h 12 Aug 2002 07:21:57 -0000 2.25
--- methodobject.h 31 Jan 2003 18:33:15 -0000 2.26
***************
*** 41,45 ****
PyAPI_FUNC(PyObject *) Py_FindMethod(PyMethodDef[], PyObject *, char *);
! PyAPI_FUNC(PyObject *) PyCFunction_New(PyMethodDef *, PyObject *);
/* Flag passed to newmethodobject */
--- 41,47 ----
PyAPI_FUNC(PyObject *) Py_FindMethod(PyMethodDef[], PyObject *, char *);
! #define PyCFunction_New(ML, SELF) PyCFunction_NewEx((ML), (SELF), NULL)
! PyAPI_FUNC(PyObject *) PyCFunction_NewEx(PyMethodDef *, PyObject *,
! PyObject *);
/* Flag passed to newmethodobject */
***************
*** 69,72 ****
--- 71,75 ----
PyMethodDef *m_ml;
PyObject *m_self;
+ PyObject *m_module;
} PyCFunctionObject;