Mercurial > cpython-lru_cache-weakref
annotate Objects/methodobject.c @ 58689:514b56efd89a 3.1
Merged revisions 77962 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r77962 | r.david.murray | 2010-02-04 11:41:57 -0500 (Thu, 04 Feb 2010) | 17 lines
Merged revisions 77943,77959-77960 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77943 | r.david.murray | 2010-02-03 08:36:23 -0500 (Wed, 03 Feb 2010) | 2 lines
Explicitly mention the default value for formatdate's usegmt parameter.
........
r77959 | nick.coghlan | 2010-02-04 07:43:58 -0500 (Thu, 04 Feb 2010) | 1 line
Issue 6760: Clarify args handling for subprocess.Popen. Patch by Chris Rebert
........
r77960 | r.david.murray | 2010-02-04 11:33:31 -0500 (Thu, 04 Feb 2010) | 2 lines
Add Chris Rebert to ACKS for issue 6760 Popen doc improvements.
........
................
| author | R. David Murray <rdmurray@bitdance.com> |
|---|---|
| date | Thu, 04 Feb 2010 16:44:31 +0000 |
| parents | 87fbbf22adf3 |
| children | cab14be0ada1 |
| rev | line source |
|---|---|
| 145 | 1 |
| 6 | 2 /* Method object implementation */ |
| 3 | |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
4 #include "Python.h" |
|
27559
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
5 #include "structmember.h" |
| 6 | 6 |
|
45192
142a11b3057e
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43893
diff
changeset
|
7 /* Free list for method objects to safe malloc/free overhead |
|
142a11b3057e
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43893
diff
changeset
|
8 * The m_self element is used to chain the objects. |
|
142a11b3057e
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43893
diff
changeset
|
9 */ |
|
5934
0369d63b100b
Added separate free list for cfunction (builtin method) objects, for a
Guido van Rossum <guido@python.org>
parents:
5396
diff
changeset
|
10 static PyCFunctionObject *free_list = NULL; |
|
45192
142a11b3057e
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43893
diff
changeset
|
11 static int numfree = 0; |
|
142a11b3057e
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43893
diff
changeset
|
12 #ifndef PyCFunction_MAXFREELIST |
|
142a11b3057e
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43893
diff
changeset
|
13 #define PyCFunction_MAXFREELIST 256 |
|
142a11b3057e
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43893
diff
changeset
|
14 #endif |
|
5934
0369d63b100b
Added separate free list for cfunction (builtin method) objects, for a
Guido van Rossum <guido@python.org>
parents:
5396
diff
changeset
|
15 |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
16 PyObject * |
|
27559
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
17 PyCFunction_NewEx(PyMethodDef *ml, PyObject *self, PyObject *module) |
| 6 | 18 { |
|
5934
0369d63b100b
Added separate free list for cfunction (builtin method) objects, for a
Guido van Rossum <guido@python.org>
parents:
5396
diff
changeset
|
19 PyCFunctionObject *op; |
|
0369d63b100b
Added separate free list for cfunction (builtin method) objects, for a
Guido van Rossum <guido@python.org>
parents:
5396
diff
changeset
|
20 op = free_list; |
| 6 | 21 if (op != NULL) { |
|
5934
0369d63b100b
Added separate free list for cfunction (builtin method) objects, for a
Guido van Rossum <guido@python.org>
parents:
5396
diff
changeset
|
22 free_list = (PyCFunctionObject *)(op->m_self); |
|
12576
1c7c2dd1beb1
Vladimir Marangozov's long-awaited malloc restructuring.
Guido van Rossum <guido@python.org>
parents:
11673
diff
changeset
|
23 PyObject_INIT(op, &PyCFunction_Type); |
|
45192
142a11b3057e
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43893
diff
changeset
|
24 numfree--; |
| 6 | 25 } |
|
5934
0369d63b100b
Added separate free list for cfunction (builtin method) objects, for a
Guido van Rossum <guido@python.org>
parents:
5396
diff
changeset
|
26 else { |
|
22397
132a064da656
Re-enable GC of method objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
20015
diff
changeset
|
27 op = PyObject_GC_New(PyCFunctionObject, &PyCFunction_Type); |
|
5934
0369d63b100b
Added separate free list for cfunction (builtin method) objects, for a
Guido van Rossum <guido@python.org>
parents:
5396
diff
changeset
|
28 if (op == NULL) |
|
0369d63b100b
Added separate free list for cfunction (builtin method) objects, for a
Guido van Rossum <guido@python.org>
parents:
5396
diff
changeset
|
29 return NULL; |
|
0369d63b100b
Added separate free list for cfunction (builtin method) objects, for a
Guido van Rossum <guido@python.org>
parents:
5396
diff
changeset
|
30 } |
|
0369d63b100b
Added separate free list for cfunction (builtin method) objects, for a
Guido van Rossum <guido@python.org>
parents:
5396
diff
changeset
|
31 op->m_ml = ml; |
|
0369d63b100b
Added separate free list for cfunction (builtin method) objects, for a
Guido van Rossum <guido@python.org>
parents:
5396
diff
changeset
|
32 Py_XINCREF(self); |
|
0369d63b100b
Added separate free list for cfunction (builtin method) objects, for a
Guido van Rossum <guido@python.org>
parents:
5396
diff
changeset
|
33 op->m_self = self; |
|
27559
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
34 Py_XINCREF(module); |
|
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
35 op->m_module = module; |
|
22397
132a064da656
Re-enable GC of method objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
20015
diff
changeset
|
36 _PyObject_GC_TRACK(op); |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
37 return (PyObject *)op; |
| 6 | 38 } |
| 39 | |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
40 PyCFunction |
|
13457
ef2ebb3b0c64
ANSI-fication of the sources.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
41 PyCFunction_GetFunction(PyObject *op) |
| 6 | 42 { |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
43 if (!PyCFunction_Check(op)) { |
|
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
44 PyErr_BadInternalCall(); |
| 6 | 45 return NULL; |
| 46 } | |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
47 return ((PyCFunctionObject *)op) -> m_ml -> ml_meth; |
| 6 | 48 } |
| 49 | |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
50 PyObject * |
|
13457
ef2ebb3b0c64
ANSI-fication of the sources.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
51 PyCFunction_GetSelf(PyObject *op) |
| 6 | 52 { |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
53 if (!PyCFunction_Check(op)) { |
|
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
54 PyErr_BadInternalCall(); |
| 6 | 55 return NULL; |
| 56 } | |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
57 return ((PyCFunctionObject *)op) -> m_self; |
| 6 | 58 } |
| 59 | |
|
488
90f35fcf8ea0
Add "varargs" attribute.
Guido van Rossum <guido@python.org>
parents:
472
diff
changeset
|
60 int |
|
13457
ef2ebb3b0c64
ANSI-fication of the sources.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
61 PyCFunction_GetFlags(PyObject *op) |
|
488
90f35fcf8ea0
Add "varargs" attribute.
Guido van Rossum <guido@python.org>
parents:
472
diff
changeset
|
62 { |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
63 if (!PyCFunction_Check(op)) { |
|
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
64 PyErr_BadInternalCall(); |
|
488
90f35fcf8ea0
Add "varargs" attribute.
Guido van Rossum <guido@python.org>
parents:
472
diff
changeset
|
65 return -1; |
|
90f35fcf8ea0
Add "varargs" attribute.
Guido van Rossum <guido@python.org>
parents:
472
diff
changeset
|
66 } |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
67 return ((PyCFunctionObject *)op) -> m_ml -> ml_flags; |
|
488
90f35fcf8ea0
Add "varargs" attribute.
Guido van Rossum <guido@python.org>
parents:
472
diff
changeset
|
68 } |
|
90f35fcf8ea0
Add "varargs" attribute.
Guido van Rossum <guido@python.org>
parents:
472
diff
changeset
|
69 |
|
19198
3c1c9948ff65
Remove much dead code from ceval.c
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18933
diff
changeset
|
70 PyObject * |
|
3c1c9948ff65
Remove much dead code from ceval.c
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18933
diff
changeset
|
71 PyCFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) |
|
3c1c9948ff65
Remove much dead code from ceval.c
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18933
diff
changeset
|
72 { |
|
3c1c9948ff65
Remove much dead code from ceval.c
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18933
diff
changeset
|
73 PyCFunctionObject* f = (PyCFunctionObject*)func; |
|
3c1c9948ff65
Remove much dead code from ceval.c
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18933
diff
changeset
|
74 PyCFunction meth = PyCFunction_GET_FUNCTION(func); |
|
3c1c9948ff65
Remove much dead code from ceval.c
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18933
diff
changeset
|
75 PyObject *self = PyCFunction_GET_SELF(func); |
|
36519
d6d415df0df0
Use Py_ssize_t for counts and sizes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36501
diff
changeset
|
76 Py_ssize_t size; |
|
19198
3c1c9948ff65
Remove much dead code from ceval.c
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18933
diff
changeset
|
77 |
|
31172
e4fb6164158c
* Added a new method flag, METH_COEXIST.
Raymond Hettinger <python@rcn.com>
parents:
27941
diff
changeset
|
78 switch (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)) { |
|
19301
b9701538f827
Patch #427190: Implement and use METH_NOARGS and METH_O.
Martin v. Löwis <martin@v.loewis.de>
parents:
19198
diff
changeset
|
79 case METH_VARARGS: |
|
27072
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
80 if (kw == NULL || PyDict_Size(kw) == 0) |
|
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
81 return (*meth)(self, arg); |
|
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
82 break; |
|
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
83 case METH_VARARGS | METH_KEYWORDS: |
|
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
84 return (*(PyCFunctionWithKeywords)meth)(self, arg, kw); |
|
19301
b9701538f827
Patch #427190: Implement and use METH_NOARGS and METH_O.
Martin v. Löwis <martin@v.loewis.de>
parents:
19198
diff
changeset
|
85 case METH_NOARGS: |
|
27072
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
86 if (kw == NULL || PyDict_Size(kw) == 0) { |
|
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
87 size = PyTuple_GET_SIZE(arg); |
|
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
88 if (size == 0) |
|
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
89 return (*meth)(self, NULL); |
|
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
90 PyErr_Format(PyExc_TypeError, |
|
36519
d6d415df0df0
Use Py_ssize_t for counts and sizes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36501
diff
changeset
|
91 "%.200s() takes no arguments (%zd given)", |
|
27072
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
92 f->m_ml->ml_name, size); |
|
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
93 return NULL; |
|
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
94 } |
|
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
95 break; |
|
19301
b9701538f827
Patch #427190: Implement and use METH_NOARGS and METH_O.
Martin v. Löwis <martin@v.loewis.de>
parents:
19198
diff
changeset
|
96 case METH_O: |
|
27072
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
97 if (kw == NULL || PyDict_Size(kw) == 0) { |
|
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
98 size = PyTuple_GET_SIZE(arg); |
|
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
99 if (size == 1) |
|
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
100 return (*meth)(self, PyTuple_GET_ITEM(arg, 0)); |
|
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
101 PyErr_Format(PyExc_TypeError, |
|
36519
d6d415df0df0
Use Py_ssize_t for counts and sizes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36501
diff
changeset
|
102 "%.200s() takes exactly one argument (%zd given)", |
|
27072
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
103 f->m_ml->ml_name, size); |
|
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
104 return NULL; |
|
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
105 } |
|
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
106 break; |
|
19301
b9701538f827
Patch #427190: Implement and use METH_NOARGS and METH_O.
Martin v. Löwis <martin@v.loewis.de>
parents:
19198
diff
changeset
|
107 default: |
| 43177 | 108 PyErr_SetString(PyExc_SystemError, "Bad call flags in " |
| 109 "PyCFunction_Call. METH_OLDARGS is no " | |
| 110 "longer supported!"); | |
| 111 | |
|
19301
b9701538f827
Patch #427190: Implement and use METH_NOARGS and METH_O.
Martin v. Löwis <martin@v.loewis.de>
parents:
19198
diff
changeset
|
112 return NULL; |
|
19198
3c1c9948ff65
Remove much dead code from ceval.c
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18933
diff
changeset
|
113 } |
|
27072
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
114 PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", |
|
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
115 f->m_ml->ml_name); |
|
1564c6839e6b
SF Patch #661440: Refactor and streamline PyCFunction_Call
Raymond Hettinger <python@rcn.com>
parents:
22613
diff
changeset
|
116 return NULL; |
|
19198
3c1c9948ff65
Remove much dead code from ceval.c
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18933
diff
changeset
|
117 } |
|
3c1c9948ff65
Remove much dead code from ceval.c
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18933
diff
changeset
|
118 |
| 6 | 119 /* Methods (the standard built-in methods, that is) */ |
| 120 | |
| 121 static void | |
|
13457
ef2ebb3b0c64
ANSI-fication of the sources.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
122 meth_dealloc(PyCFunctionObject *m) |
| 6 | 123 { |
|
22397
132a064da656
Re-enable GC of method objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
20015
diff
changeset
|
124 _PyObject_GC_UNTRACK(m); |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
125 Py_XDECREF(m->m_self); |
|
27559
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
126 Py_XDECREF(m->m_module); |
|
45192
142a11b3057e
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43893
diff
changeset
|
127 if (numfree < PyCFunction_MAXFREELIST) { |
|
142a11b3057e
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43893
diff
changeset
|
128 m->m_self = (PyObject *)free_list; |
|
142a11b3057e
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43893
diff
changeset
|
129 free_list = m; |
|
142a11b3057e
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43893
diff
changeset
|
130 numfree++; |
|
142a11b3057e
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43893
diff
changeset
|
131 } |
|
142a11b3057e
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43893
diff
changeset
|
132 else { |
|
142a11b3057e
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43893
diff
changeset
|
133 PyObject_GC_Del(m); |
|
142a11b3057e
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43893
diff
changeset
|
134 } |
| 6 | 135 } |
| 136 | |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
137 static PyObject * |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
138 meth_get__doc__(PyCFunctionObject *m, void *closure) |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
139 { |
|
35999
9541369b0dca
Add const to several API functions that take char *.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
31172
diff
changeset
|
140 const char *doc = m->m_ml->ml_doc; |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
141 |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
142 if (doc != NULL) |
|
42755
42b39cb536d9
CFunctions' doc strings should be Unicode.
Guido van Rossum <guido@python.org>
parents:
42537
diff
changeset
|
143 return PyUnicode_FromString(doc); |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
144 Py_INCREF(Py_None); |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
145 return Py_None; |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
146 } |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
147 |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
148 static PyObject * |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
149 meth_get__name__(PyCFunctionObject *m, void *closure) |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
150 { |
|
42013
cd125fe83051
Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents:
41769
diff
changeset
|
151 return PyUnicode_FromString(m->m_ml->ml_name); |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
152 } |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
153 |
|
18512
b2bf88e06fc5
GC for method objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
14375
diff
changeset
|
154 static int |
|
b2bf88e06fc5
GC for method objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
14375
diff
changeset
|
155 meth_traverse(PyCFunctionObject *m, visitproc visit, void *arg) |
|
b2bf88e06fc5
GC for method objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
14375
diff
changeset
|
156 { |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36519
diff
changeset
|
157 Py_VISIT(m->m_self); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36519
diff
changeset
|
158 Py_VISIT(m->m_module); |
|
27559
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
159 return 0; |
|
18512
b2bf88e06fc5
GC for method objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
14375
diff
changeset
|
160 } |
|
b2bf88e06fc5
GC for method objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
14375
diff
changeset
|
161 |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
162 static PyObject * |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
163 meth_get__self__(PyCFunctionObject *m, void *closure) |
|
2083
f2d267edbfd6
* Objects/methodobject.c: changed drastically, the object now
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
164 { |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
165 PyObject *self; |
|
41715
f60c877d52c8
Merged revisions 55270-55324 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
39644
diff
changeset
|
166 |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
167 self = m->m_self; |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
168 if (self == NULL) |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
169 self = Py_None; |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
170 Py_INCREF(self); |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
171 return self; |
|
2083
f2d267edbfd6
* Objects/methodobject.c: changed drastically, the object now
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
172 } |
|
f2d267edbfd6
* Objects/methodobject.c: changed drastically, the object now
Guido van Rossum <guido@python.org>
parents:
2059
diff
changeset
|
173 |
|
20015
ca7af2a5d915
Add optional docstrings to getset descriptors. Fortunately, there's
Guido van Rossum <guido@python.org>
parents:
19599
diff
changeset
|
174 static PyGetSetDef meth_getsets [] = { |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
175 {"__doc__", (getter)meth_get__doc__, NULL, NULL}, |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
176 {"__name__", (getter)meth_get__name__, NULL, NULL}, |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
177 {"__self__", (getter)meth_get__self__, NULL, NULL}, |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
178 {0} |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
179 }; |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
180 |
|
27559
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
181 #define OFF(x) offsetof(PyCFunctionObject, x) |
|
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
182 |
|
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
183 static PyMemberDef meth_members[] = { |
|
43893
483e958d13c7
Fixed some build issues and updated docs.
Christian Heimes <christian@cheimes.de>
parents:
43177
diff
changeset
|
184 {"__module__", T_OBJECT, OFF(m_module), PY_WRITE_RESTRICTED}, |
|
27559
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
185 {NULL} |
|
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
186 }; |
|
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
187 |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
188 static PyObject * |
|
13457
ef2ebb3b0c64
ANSI-fication of the sources.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
189 meth_repr(PyCFunctionObject *m) |
| 6 | 190 { |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
45371
diff
changeset
|
191 if (m->m_self == NULL || PyModule_Check(m->m_self)) |
|
41769
b29d71d43c80
Add functions PyUnicode_Append() and PyUnicode_AppendAndDel() that mirror
Walter Dörwald <walter@livinglogic.de>
parents:
41715
diff
changeset
|
192 return PyUnicode_FromFormat("<built-in function %s>", |
|
19476
0e70df98424e
repr's converted to using PyString_FromFormat() instead of sprintf'ing
Barry Warsaw <barry@python.org>
parents:
19301
diff
changeset
|
193 m->m_ml->ml_name); |
|
41769
b29d71d43c80
Add functions PyUnicode_Append() and PyUnicode_AppendAndDel() that mirror
Walter Dörwald <walter@livinglogic.de>
parents:
41715
diff
changeset
|
194 return PyUnicode_FromFormat("<built-in method %s of %s object at %p>", |
|
19476
0e70df98424e
repr's converted to using PyString_FromFormat() instead of sprintf'ing
Barry Warsaw <barry@python.org>
parents:
19301
diff
changeset
|
195 m->m_ml->ml_name, |
|
0e70df98424e
repr's converted to using PyString_FromFormat() instead of sprintf'ing
Barry Warsaw <barry@python.org>
parents:
19301
diff
changeset
|
196 m->m_self->ob_type->tp_name, |
|
0e70df98424e
repr's converted to using PyString_FromFormat() instead of sprintf'ing
Barry Warsaw <barry@python.org>
parents:
19301
diff
changeset
|
197 m->m_self); |
| 6 | 198 } |
| 199 | |
|
39644
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
37879
diff
changeset
|
200 static PyObject * |
|
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
37879
diff
changeset
|
201 meth_richcompare(PyObject *self, PyObject *other, int op) |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
202 { |
|
39644
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
37879
diff
changeset
|
203 PyCFunctionObject *a, *b; |
|
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
37879
diff
changeset
|
204 PyObject *res; |
|
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
37879
diff
changeset
|
205 int eq; |
|
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
37879
diff
changeset
|
206 |
|
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
37879
diff
changeset
|
207 if ((op != Py_EQ && op != Py_NE) || |
|
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
37879
diff
changeset
|
208 !PyCFunction_Check(self) || |
|
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
37879
diff
changeset
|
209 !PyCFunction_Check(other)) |
|
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
37879
diff
changeset
|
210 { |
|
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
37879
diff
changeset
|
211 Py_INCREF(Py_NotImplemented); |
|
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
37879
diff
changeset
|
212 return Py_NotImplemented; |
|
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
37879
diff
changeset
|
213 } |
|
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
37879
diff
changeset
|
214 a = (PyCFunctionObject *)self; |
|
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
37879
diff
changeset
|
215 b = (PyCFunctionObject *)other; |
|
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
37879
diff
changeset
|
216 eq = a->m_self == b->m_self; |
|
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
37879
diff
changeset
|
217 if (eq) |
|
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
37879
diff
changeset
|
218 eq = a->m_ml->ml_meth == b->m_ml->ml_meth; |
|
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
37879
diff
changeset
|
219 if (op == Py_EQ) |
|
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
37879
diff
changeset
|
220 res = eq ? Py_True : Py_False; |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
221 else |
|
39644
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
37879
diff
changeset
|
222 res = eq ? Py_False : Py_True; |
|
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
37879
diff
changeset
|
223 Py_INCREF(res); |
|
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
37879
diff
changeset
|
224 return res; |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
225 } |
|
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
226 |
|
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
227 static long |
|
13457
ef2ebb3b0c64
ANSI-fication of the sources.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
228 meth_hash(PyCFunctionObject *a) |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
229 { |
|
13141
cca84745da3e
This patch addresses two main issues: (1) There exist some non-fatal
Fred Drake <fdrake@acm.org>
parents:
12576
diff
changeset
|
230 long x,y; |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
231 if (a->m_self == NULL) |
|
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
232 x = 0; |
|
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
233 else { |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
234 x = PyObject_Hash(a->m_self); |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
235 if (x == -1) |
|
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
236 return -1; |
|
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
237 } |
|
13252
310d7cbba329
Fix an error on AIX by using a proper cast.
Guido van Rossum <guido@python.org>
parents:
13210
diff
changeset
|
238 y = _Py_HashPointer((void*)(a->m_ml->ml_meth)); |
|
13141
cca84745da3e
This patch addresses two main issues: (1) There exist some non-fatal
Fred Drake <fdrake@acm.org>
parents:
12576
diff
changeset
|
239 if (y == -1) |
|
cca84745da3e
This patch addresses two main issues: (1) There exist some non-fatal
Fred Drake <fdrake@acm.org>
parents:
12576
diff
changeset
|
240 return -1; |
|
cca84745da3e
This patch addresses two main issues: (1) There exist some non-fatal
Fred Drake <fdrake@acm.org>
parents:
12576
diff
changeset
|
241 x ^= y; |
|
cca84745da3e
This patch addresses two main issues: (1) There exist some non-fatal
Fred Drake <fdrake@acm.org>
parents:
12576
diff
changeset
|
242 if (x == -1) |
|
cca84745da3e
This patch addresses two main issues: (1) There exist some non-fatal
Fred Drake <fdrake@acm.org>
parents:
12576
diff
changeset
|
243 x = -2; |
|
cca84745da3e
This patch addresses two main issues: (1) There exist some non-fatal
Fred Drake <fdrake@acm.org>
parents:
12576
diff
changeset
|
244 return x; |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
245 } |
|
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
246 |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
247 |
|
5396
d1447950fa04
Quickly renamed the last directory.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
248 PyTypeObject PyCFunction_Type = { |
|
42334
e70cdce0e8b2
Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
42013
diff
changeset
|
249 PyVarObject_HEAD_INIT(&PyType_Type, 0) |
|
1051
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
250 "builtin_function_or_method", |
|
22397
132a064da656
Re-enable GC of method objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
20015
diff
changeset
|
251 sizeof(PyCFunctionObject), |
| 6 | 252 0, |
|
18512
b2bf88e06fc5
GC for method objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
14375
diff
changeset
|
253 (destructor)meth_dealloc, /* tp_dealloc */ |
|
b2bf88e06fc5
GC for method objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
14375
diff
changeset
|
254 0, /* tp_print */ |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
255 0, /* tp_getattr */ |
|
18512
b2bf88e06fc5
GC for method objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
14375
diff
changeset
|
256 0, /* tp_setattr */ |
|
51271
87fbbf22adf3
Merged revisions 69214 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents:
48418
diff
changeset
|
257 0, /* tp_reserved */ |
|
18512
b2bf88e06fc5
GC for method objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
14375
diff
changeset
|
258 (reprfunc)meth_repr, /* tp_repr */ |
|
b2bf88e06fc5
GC for method objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
14375
diff
changeset
|
259 0, /* tp_as_number */ |
|
b2bf88e06fc5
GC for method objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
14375
diff
changeset
|
260 0, /* tp_as_sequence */ |
|
b2bf88e06fc5
GC for method objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
14375
diff
changeset
|
261 0, /* tp_as_mapping */ |
|
b2bf88e06fc5
GC for method objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
14375
diff
changeset
|
262 (hashfunc)meth_hash, /* tp_hash */ |
|
19198
3c1c9948ff65
Remove much dead code from ceval.c
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
18933
diff
changeset
|
263 PyCFunction_Call, /* tp_call */ |
|
18512
b2bf88e06fc5
GC for method objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
14375
diff
changeset
|
264 0, /* tp_str */ |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
265 PyObject_GenericGetAttr, /* tp_getattro */ |
|
18512
b2bf88e06fc5
GC for method objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
14375
diff
changeset
|
266 0, /* tp_setattro */ |
|
b2bf88e06fc5
GC for method objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
14375
diff
changeset
|
267 0, /* tp_as_buffer */ |
|
22397
132a064da656
Re-enable GC of method objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
20015
diff
changeset
|
268 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ |
|
18512
b2bf88e06fc5
GC for method objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
14375
diff
changeset
|
269 0, /* tp_doc */ |
|
b2bf88e06fc5
GC for method objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
14375
diff
changeset
|
270 (traverseproc)meth_traverse, /* tp_traverse */ |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
271 0, /* tp_clear */ |
|
39644
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
37879
diff
changeset
|
272 meth_richcompare, /* tp_richcompare */ |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
273 0, /* tp_weaklistoffset */ |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
274 0, /* tp_iter */ |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
275 0, /* tp_iternext */ |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
276 0, /* tp_methods */ |
|
27559
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
277 meth_members, /* tp_members */ |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
278 meth_getsets, /* tp_getset */ |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
279 0, /* tp_base */ |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
18512
diff
changeset
|
280 0, /* tp_dict */ |
| 6 | 281 }; |
| 86 | 282 |
|
5934
0369d63b100b
Added separate free list for cfunction (builtin method) objects, for a
Guido van Rossum <guido@python.org>
parents:
5396
diff
changeset
|
283 /* Clear out the free list */ |
|
0369d63b100b
Added separate free list for cfunction (builtin method) objects, for a
Guido van Rossum <guido@python.org>
parents:
5396
diff
changeset
|
284 |
|
45371
7c4c46342137
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45192
diff
changeset
|
285 int |
|
7c4c46342137
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45192
diff
changeset
|
286 PyCFunction_ClearFreeList(void) |
|
5934
0369d63b100b
Added separate free list for cfunction (builtin method) objects, for a
Guido van Rossum <guido@python.org>
parents:
5396
diff
changeset
|
287 { |
|
45371
7c4c46342137
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45192
diff
changeset
|
288 int freelist_size = numfree; |
|
7c4c46342137
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45192
diff
changeset
|
289 |
|
5934
0369d63b100b
Added separate free list for cfunction (builtin method) objects, for a
Guido van Rossum <guido@python.org>
parents:
5396
diff
changeset
|
290 while (free_list) { |
|
0369d63b100b
Added separate free list for cfunction (builtin method) objects, for a
Guido van Rossum <guido@python.org>
parents:
5396
diff
changeset
|
291 PyCFunctionObject *v = free_list; |
|
0369d63b100b
Added separate free list for cfunction (builtin method) objects, for a
Guido van Rossum <guido@python.org>
parents:
5396
diff
changeset
|
292 free_list = (PyCFunctionObject *)(v->m_self); |
|
22397
132a064da656
Re-enable GC of method objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
20015
diff
changeset
|
293 PyObject_GC_Del(v); |
|
45192
142a11b3057e
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43893
diff
changeset
|
294 numfree--; |
|
5934
0369d63b100b
Added separate free list for cfunction (builtin method) objects, for a
Guido van Rossum <guido@python.org>
parents:
5396
diff
changeset
|
295 } |
|
45192
142a11b3057e
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43893
diff
changeset
|
296 assert(numfree == 0); |
|
45371
7c4c46342137
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45192
diff
changeset
|
297 return freelist_size; |
|
7c4c46342137
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45192
diff
changeset
|
298 } |
|
7c4c46342137
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45192
diff
changeset
|
299 |
|
7c4c46342137
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45192
diff
changeset
|
300 void |
|
7c4c46342137
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45192
diff
changeset
|
301 PyCFunction_Fini(void) |
|
7c4c46342137
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45192
diff
changeset
|
302 { |
|
7c4c46342137
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45192
diff
changeset
|
303 (void)PyCFunction_ClearFreeList(); |
|
5934
0369d63b100b
Added separate free list for cfunction (builtin method) objects, for a
Guido van Rossum <guido@python.org>
parents:
5396
diff
changeset
|
304 } |
|
27559
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
305 |
|
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
306 /* PyCFunction_New() is now just a macro that calls PyCFunction_NewEx(), |
|
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
307 but it's part of the API so we need to keep a function around that |
|
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
308 existing C extensions can call. |
|
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
309 */ |
|
45192
142a11b3057e
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43893
diff
changeset
|
310 |
|
27559
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
311 #undef PyCFunction_New |
|
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
312 PyAPI_FUNC(PyObject *) PyCFunction_New(PyMethodDef *, PyObject *); |
|
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
313 |
|
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
314 PyObject * |
|
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
315 PyCFunction_New(PyMethodDef *ml, PyObject *self) |
|
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
316 { |
|
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
317 return PyCFunction_NewEx(ml, self, NULL); |
|
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27093
diff
changeset
|
318 } |
