annotate Include/funcobject.h @ 58664:993f703a61ba

Merged revisions 77484,77487,77561,77570,77593,77603,77608,77667,77702-77703,77739,77858,77887,77889 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r77484 | skip.montanaro | 2010-01-13 19:12:34 -0600 (Wed, 13 Jan 2010) | 4 lines Update PyEval_EvalFrame to PyEval_EvalFrameEx. This looks to have been done partially before. Also add a comment describing how this might have to work with different versions of the interpreter. ........ r77487 | ezio.melotti | 2010-01-14 05:34:10 -0600 (Thu, 14 Jan 2010) | 1 line Fixed typo ........ r77561 | georg.brandl | 2010-01-17 02:42:30 -0600 (Sun, 17 Jan 2010) | 1 line #7699: improve datetime docs: straightforward linking to strftime/strptime section, mark classmethods as such. ........ r77570 | georg.brandl | 2010-01-17 06:14:42 -0600 (Sun, 17 Jan 2010) | 1 line Add note about usage of STRINGLIB_EMPTY. ........ r77593 | georg.brandl | 2010-01-17 17:33:53 -0600 (Sun, 17 Jan 2010) | 1 line Fix internal reference. ........ r77603 | benjamin.peterson | 2010-01-18 17:07:56 -0600 (Mon, 18 Jan 2010) | 8 lines data descriptors do not override the class dictionary if __get__ is not defined Adjust documentation and add a test to verify this behavior. See http://mail.python.org/pipermail/python-dev/2010-January/095637.html for discussion. ........ r77608 | gregory.p.smith | 2010-01-19 02:19:03 -0600 (Tue, 19 Jan 2010) | 6 lines Do not compile stubs for the sha2 series hashes in the openssl hashlib module when the openssl version is too old to support them. That leads both compiled code bloat and to unittests attempting to test implementations that don't exist for comparison purposes on such platforms. ........ r77667 | mark.dickinson | 2010-01-21 12:32:27 -0600 (Thu, 21 Jan 2010) | 1 line Add two more test_strtod test values. ........ r77702 | georg.brandl | 2010-01-23 02:43:31 -0600 (Sat, 23 Jan 2010) | 1 line #7762: fix refcount annotation of PyUnicode_Tailmatch(). ........ r77703 | georg.brandl | 2010-01-23 02:47:54 -0600 (Sat, 23 Jan 2010) | 1 line #7725: fix referencing issue. ........ r77739 | benjamin.peterson | 2010-01-24 21:52:52 -0600 (Sun, 24 Jan 2010) | 1 line mention from_float() in error message ........ r77858 | georg.brandl | 2010-01-30 11:57:48 -0600 (Sat, 30 Jan 2010) | 1 line #7802: fix invalid example (heh). ........ r77887 | georg.brandl | 2010-01-31 12:51:49 -0600 (Sun, 31 Jan 2010) | 5 lines Fix-up ftplib documentation: move exception descriptions to toplevel, not inside a class remove attribution in "versionadded" spell and grammar check docstring of FTP_TLS ........ r77889 | michael.foord | 2010-01-31 13:59:26 -0600 (Sun, 31 Jan 2010) | 1 line Minor modification to unittest documentation. ........
author Benjamin Peterson <benjamin@python.org>
date Wed, 03 Feb 2010 02:35:45 +0000
parents 86a2679dca46
children 62b61abd02b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
145
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 85
diff changeset
1
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 /* Function object interface */
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
4 #ifndef Py_FUNCOBJECT_H
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
5 #define Py_FUNCOBJECT_H
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
6 #ifdef __cplusplus
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
7 extern "C" {
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
8 #endif
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
9
33856
60c60dc75c77 Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents: 27559
diff changeset
10 /* Function objects and code objects should not be confused with each other:
60c60dc75c77 Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents: 27559
diff changeset
11 *
60c60dc75c77 Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents: 27559
diff changeset
12 * Function objects are created by the execution of the 'def' statement.
42832
cafe1f653db3 Fix some comments
Neal Norwitz <nnorwitz@gmail.com>
parents: 42334
diff changeset
13 * They reference a code object in their __code__ attribute, which is a
33856
60c60dc75c77 Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents: 27559
diff changeset
14 * purely syntactic object, i.e. nothing more than a compiled version of some
60c60dc75c77 Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents: 27559
diff changeset
15 * source code lines. There is one code object per source code "fragment",
60c60dc75c77 Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents: 27559
diff changeset
16 * but each code object can be referenced by zero or many function objects
60c60dc75c77 Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents: 27559
diff changeset
17 * depending only on how many times the 'def' statement in the source was
60c60dc75c77 Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents: 27559
diff changeset
18 * executed so far.
60c60dc75c77 Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents: 27559
diff changeset
19 */
60c60dc75c77 Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents: 27559
diff changeset
20
1288
9fed5726a36d Several changes in one:
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
21 typedef struct {
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
22 PyObject_HEAD
42832
cafe1f653db3 Fix some comments
Neal Norwitz <nnorwitz@gmail.com>
parents: 42334
diff changeset
23 PyObject *func_code; /* A code object, the __code__ attribute */
33856
60c60dc75c77 Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents: 27559
diff changeset
24 PyObject *func_globals; /* A dictionary (other mappings won't do) */
60c60dc75c77 Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents: 27559
diff changeset
25 PyObject *func_defaults; /* NULL or a tuple */
40215
1cce0526d9b0 Jiwon Seo's PEP 3102 implementation.
Guido van Rossum <guido@python.org>
parents: 33856
diff changeset
26 PyObject *func_kwdefaults; /* NULL or a dict */
33856
60c60dc75c77 Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents: 27559
diff changeset
27 PyObject *func_closure; /* NULL or a tuple of cell objects */
60c60dc75c77 Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents: 27559
diff changeset
28 PyObject *func_doc; /* The __doc__ attribute, can be anything */
60c60dc75c77 Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents: 27559
diff changeset
29 PyObject *func_name; /* The __name__ attribute, a string object */
60c60dc75c77 Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents: 27559
diff changeset
30 PyObject *func_dict; /* The __dict__ attribute, a dict or NULL */
60c60dc75c77 Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents: 27559
diff changeset
31 PyObject *func_weakreflist; /* List of weak references */
60c60dc75c77 Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents: 27559
diff changeset
32 PyObject *func_module; /* The __module__ attribute, can be anything */
40529
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
33 PyObject *func_annotations; /* Annotations, a dict or NULL */
33856
60c60dc75c77 Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents: 27559
diff changeset
34
60c60dc75c77 Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents: 27559
diff changeset
35 /* Invariant:
60c60dc75c77 Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents: 27559
diff changeset
36 * func_closure contains the bindings for func_code->co_freevars, so
60c60dc75c77 Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents: 27559
diff changeset
37 * PyTuple_Size(func_closure) == PyCode_GetNumFree(func_code)
60c60dc75c77 Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents: 27559
diff changeset
38 * (func_closure may be NULL if PyCode_GetNumFree(func_code) == 0).
60c60dc75c77 Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents: 27559
diff changeset
39 */
2129
05360cd616ae The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents: 2073
diff changeset
40 } PyFunctionObject;
1288
9fed5726a36d Several changes in one:
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
41
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18933
diff changeset
42 PyAPI_DATA(PyTypeObject) PyFunction_Type;
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
43
44351
86a2679dca46 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents: 42832
diff changeset
44 #define PyFunction_Check(op) (Py_TYPE(op) == &PyFunction_Type)
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
45
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18933
diff changeset
46 PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18933
diff changeset
47 PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18933
diff changeset
48 PyAPI_FUNC(PyObject *) PyFunction_GetGlobals(PyObject *);
27559
faabd9867fb8 Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 24752
diff changeset
49 PyAPI_FUNC(PyObject *) PyFunction_GetModule(PyObject *);
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18933
diff changeset
50 PyAPI_FUNC(PyObject *) PyFunction_GetDefaults(PyObject *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18933
diff changeset
51 PyAPI_FUNC(int) PyFunction_SetDefaults(PyObject *, PyObject *);
40215
1cce0526d9b0 Jiwon Seo's PEP 3102 implementation.
Guido van Rossum <guido@python.org>
parents: 33856
diff changeset
52 PyAPI_FUNC(PyObject *) PyFunction_GetKwDefaults(PyObject *);
1cce0526d9b0 Jiwon Seo's PEP 3102 implementation.
Guido van Rossum <guido@python.org>
parents: 33856
diff changeset
53 PyAPI_FUNC(int) PyFunction_SetKwDefaults(PyObject *, PyObject *);
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18933
diff changeset
54 PyAPI_FUNC(PyObject *) PyFunction_GetClosure(PyObject *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18933
diff changeset
55 PyAPI_FUNC(int) PyFunction_SetClosure(PyObject *, PyObject *);
40529
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
56 PyAPI_FUNC(PyObject *) PyFunction_GetAnnotations(PyObject *);
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
57 PyAPI_FUNC(int) PyFunction_SetAnnotations(PyObject *, PyObject *);
1329
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1288
diff changeset
58
8658
1e93fa021405 Add macros for direct access to the members of CFunction objects.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
59 /* Macros for direct access to these values. Type checks are *not*
1e93fa021405 Add macros for direct access to the members of CFunction objects.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
60 done, so use with care. */
1e93fa021405 Add macros for direct access to the members of CFunction objects.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
61 #define PyFunction_GET_CODE(func) \
1e93fa021405 Add macros for direct access to the members of CFunction objects.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
62 (((PyFunctionObject *)func) -> func_code)
1e93fa021405 Add macros for direct access to the members of CFunction objects.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
63 #define PyFunction_GET_GLOBALS(func) \
1e93fa021405 Add macros for direct access to the members of CFunction objects.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
64 (((PyFunctionObject *)func) -> func_globals)
27559
faabd9867fb8 Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 24752
diff changeset
65 #define PyFunction_GET_MODULE(func) \
faabd9867fb8 Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 24752
diff changeset
66 (((PyFunctionObject *)func) -> func_module)
8658
1e93fa021405 Add macros for direct access to the members of CFunction objects.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
67 #define PyFunction_GET_DEFAULTS(func) \
1e93fa021405 Add macros for direct access to the members of CFunction objects.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
68 (((PyFunctionObject *)func) -> func_defaults)
40215
1cce0526d9b0 Jiwon Seo's PEP 3102 implementation.
Guido van Rossum <guido@python.org>
parents: 33856
diff changeset
69 #define PyFunction_GET_KW_DEFAULTS(func) \
1cce0526d9b0 Jiwon Seo's PEP 3102 implementation.
Guido van Rossum <guido@python.org>
parents: 33856
diff changeset
70 (((PyFunctionObject *)func) -> func_kwdefaults)
16257
fd8c7203251f PEP 227 implementation
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 15894
diff changeset
71 #define PyFunction_GET_CLOSURE(func) \
fd8c7203251f PEP 227 implementation
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 15894
diff changeset
72 (((PyFunctionObject *)func) -> func_closure)
40529
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
73 #define PyFunction_GET_ANNOTATIONS(func) \
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
74 (((PyFunctionObject *)func) -> func_annotations)
8658
1e93fa021405 Add macros for direct access to the members of CFunction objects.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
75
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents: 17169
diff changeset
76 /* The classmethod and staticmethod types lives here, too */
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18933
diff changeset
77 PyAPI_DATA(PyTypeObject) PyClassMethod_Type;
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18933
diff changeset
78 PyAPI_DATA(PyTypeObject) PyStaticMethod_Type;
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents: 17169
diff changeset
79
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18933
diff changeset
80 PyAPI_FUNC(PyObject *) PyClassMethod_New(PyObject *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18933
diff changeset
81 PyAPI_FUNC(PyObject *) PyStaticMethod_New(PyObject *);
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents: 17169
diff changeset
82
1329
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1288
diff changeset
83 #ifdef __cplusplus
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1288
diff changeset
84 }
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1288
diff changeset
85 #endif
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1288
diff changeset
86 #endif /* !Py_FUNCOBJECT_H */