Mercurial > cpython-lru_cache-weakref
annotate Modules/_weakref.c @ 56121:ea697cde6882 3.1
Merged revisions 74881-74885,74888,74891-74895,74900,74905-74906,74931-74932,74934,74941-74942,74944,74956 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r74881 | r.david.murray | 2009-09-17 15:12:49 -0400 (Thu, 17 Sep 2009) | 2 lines
Check in first draft of maintainers.rst.
........
r74882 | eric.smith | 2009-09-17 15:22:30 -0400 (Thu, 17 Sep 2009) | 1 line
Typo.
........
r74883 | mark.dickinson | 2009-09-17 15:37:28 -0400 (Thu, 17 Sep 2009) | 1 line
Add some more module maintainers.
........
r74884 | mark.dickinson | 2009-09-17 15:39:12 -0400 (Thu, 17 Sep 2009) | 1 line
Revert accidental changes to Objects/longobject.c
........
r74885 | mark.dickinson | 2009-09-17 16:20:01 -0400 (Thu, 17 Sep 2009) | 1 line
Add decimal maintainers
........
r74888 | r.david.murray | 2009-09-17 18:10:48 -0400 (Thu, 17 Sep 2009) | 2 lines
Maintainer additions from MAL.
........
r74891 | georg.brandl | 2009-09-17 18:18:01 -0400 (Thu, 17 Sep 2009) | 1 line
Some more maintainers.
........
r74892 | r.david.murray | 2009-09-17 19:23:56 -0400 (Thu, 17 Sep 2009) | 2 lines
Add a couple interest areas for Nick per his request.
........
r74893 | r.david.murray | 2009-09-17 19:43:20 -0400 (Thu, 17 Sep 2009) | 2 lines
Benajmin is also compiler-knowledgeable.
........
r74894 | alexandre.vassalotti | 2009-09-17 20:59:05 -0400 (Thu, 17 Sep 2009) | 2 lines
Added myself to my areas of interest.
........
r74895 | brett.cannon | 2009-09-17 21:03:35 -0400 (Thu, 17 Sep 2009) | 1 line
Add myself to a couple places as maintainer.
........
r74900 | georg.brandl | 2009-09-18 05:06:37 -0400 (Fri, 18 Sep 2009) | 1 line
Add myself in interest areas.
........
r74905 | ezio.melotti | 2009-09-18 05:58:43 -0400 (Fri, 18 Sep 2009) | 1 line
Add myself in interest areas and mark effbot as inactive in winsound
........
r74906 | antoine.pitrou | 2009-09-18 09:15:23 -0400 (Fri, 18 Sep 2009) | 3 lines
Add myself in a couple of places
........
r74931 | r.david.murray | 2009-09-18 17:25:36 -0400 (Fri, 18 Sep 2009) | 5 lines
Add some names gleaned from the "Tracker Archeology" thread
on python-dev from back in February. Also consolidate
the autoconf and makefiles topics into one, and add tracker
and svn/hg topics.
........
r74932 | r.david.murray | 2009-09-18 17:32:16 -0400 (Fri, 18 Sep 2009) | 2 lines
Remove non-committer mistakenly added.
........
r74934 | r.david.murray | 2009-09-18 17:40:30 -0400 (Fri, 18 Sep 2009) | 2 lines
More descriptive/generic name for the svn/hg entry (version control)
........
r74941 | benjamin.peterson | 2009-09-18 18:45:59 -0400 (Fri, 18 Sep 2009) | 1 line
add a new category for myself
........
r74942 | benjamin.peterson | 2009-09-18 18:50:55 -0400 (Fri, 18 Sep 2009) | 1 line
add myself for symtable
........
r74944 | georg.brandl | 2009-09-19 03:39:05 -0400 (Sat, 19 Sep 2009) | 1 line
I would like to maintain the token module!
........
r74956 | r.david.murray | 2009-09-19 14:40:08 -0400 (Sat, 19 Sep 2009) | 3 lines
Add everyone who we know has been a release manager
as a resource for the 'release management' topic.
........
| author | R. David Murray <rdmurray@bitdance.com> |
|---|---|
| date | Sat, 19 Sep 2009 19:04:37 +0000 |
| parents | 94f64f11fdd0 |
| children | 8fde1a2c94dc |
| rev | line source |
|---|---|
|
16385
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
1 #include "Python.h" |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
2 |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
3 |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
4 #define GET_WEAKREFS_LISTPTR(o) \ |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
5 ((PyWeakReference **) PyObject_GET_WEAKREFS_LISTPTR(o)) |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
6 |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
7 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
20634
diff
changeset
|
8 PyDoc_STRVAR(weakref_getweakrefcount__doc__, |
|
16659
deec6fa80471
Move docstrings out of function table to constants defined near the
Fred Drake <fdrake@acm.org>
parents:
16434
diff
changeset
|
9 "getweakrefcount(object) -- return the number of weak references\n" |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
20634
diff
changeset
|
10 "to 'object'."); |
|
16659
deec6fa80471
Move docstrings out of function table to constants defined near the
Fred Drake <fdrake@acm.org>
parents:
16434
diff
changeset
|
11 |
|
16385
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
12 static PyObject * |
|
19306
a7bbac69c8ef
Use METH_O where possible (two functions). This does not lead to real
Fred Drake <fdrake@acm.org>
parents:
17670
diff
changeset
|
13 weakref_getweakrefcount(PyObject *self, PyObject *object) |
|
16385
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
14 { |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
15 PyObject *result = NULL; |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
16 |
|
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:
44099
diff
changeset
|
17 if (PyType_SUPPORTS_WEAKREFS(Py_TYPE(object))) { |
|
19306
a7bbac69c8ef
Use METH_O where possible (two functions). This does not lead to real
Fred Drake <fdrake@acm.org>
parents:
17670
diff
changeset
|
18 PyWeakReference **list = GET_WEAKREFS_LISTPTR(object); |
|
16385
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
19 |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
42334
diff
changeset
|
20 result = PyLong_FromSsize_t(_PyWeakref_GetWeakrefCount(*list)); |
|
16385
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
21 } |
|
19306
a7bbac69c8ef
Use METH_O where possible (two functions). This does not lead to real
Fred Drake <fdrake@acm.org>
parents:
17670
diff
changeset
|
22 else |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
42334
diff
changeset
|
23 result = PyLong_FromLong(0); |
|
19306
a7bbac69c8ef
Use METH_O where possible (two functions). This does not lead to real
Fred Drake <fdrake@acm.org>
parents:
17670
diff
changeset
|
24 |
|
16385
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
25 return result; |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
26 } |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
27 |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
28 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
20634
diff
changeset
|
29 PyDoc_STRVAR(weakref_getweakrefs__doc__, |
|
16659
deec6fa80471
Move docstrings out of function table to constants defined near the
Fred Drake <fdrake@acm.org>
parents:
16434
diff
changeset
|
30 "getweakrefs(object) -- return a list of all weak reference objects\n" |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
20634
diff
changeset
|
31 "that point to 'object'."); |
|
16659
deec6fa80471
Move docstrings out of function table to constants defined near the
Fred Drake <fdrake@acm.org>
parents:
16434
diff
changeset
|
32 |
|
16385
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
33 static PyObject * |
|
19306
a7bbac69c8ef
Use METH_O where possible (two functions). This does not lead to real
Fred Drake <fdrake@acm.org>
parents:
17670
diff
changeset
|
34 weakref_getweakrefs(PyObject *self, PyObject *object) |
|
16385
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
35 { |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
36 PyObject *result = NULL; |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
37 |
|
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:
44099
diff
changeset
|
38 if (PyType_SUPPORTS_WEAKREFS(Py_TYPE(object))) { |
|
19306
a7bbac69c8ef
Use METH_O where possible (two functions). This does not lead to real
Fred Drake <fdrake@acm.org>
parents:
17670
diff
changeset
|
39 PyWeakReference **list = GET_WEAKREFS_LISTPTR(object); |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
32472
diff
changeset
|
40 Py_ssize_t count = _PyWeakref_GetWeakrefCount(*list); |
|
16385
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
41 |
|
19306
a7bbac69c8ef
Use METH_O where possible (two functions). This does not lead to real
Fred Drake <fdrake@acm.org>
parents:
17670
diff
changeset
|
42 result = PyList_New(count); |
|
a7bbac69c8ef
Use METH_O where possible (two functions). This does not lead to real
Fred Drake <fdrake@acm.org>
parents:
17670
diff
changeset
|
43 if (result != NULL) { |
|
a7bbac69c8ef
Use METH_O where possible (two functions). This does not lead to real
Fred Drake <fdrake@acm.org>
parents:
17670
diff
changeset
|
44 PyWeakReference *current = *list; |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
32472
diff
changeset
|
45 Py_ssize_t i; |
|
19306
a7bbac69c8ef
Use METH_O where possible (two functions). This does not lead to real
Fred Drake <fdrake@acm.org>
parents:
17670
diff
changeset
|
46 for (i = 0; i < count; ++i) { |
|
a7bbac69c8ef
Use METH_O where possible (two functions). This does not lead to real
Fred Drake <fdrake@acm.org>
parents:
17670
diff
changeset
|
47 PyList_SET_ITEM(result, i, (PyObject *) current); |
|
a7bbac69c8ef
Use METH_O where possible (two functions). This does not lead to real
Fred Drake <fdrake@acm.org>
parents:
17670
diff
changeset
|
48 Py_INCREF(current); |
|
a7bbac69c8ef
Use METH_O where possible (two functions). This does not lead to real
Fred Drake <fdrake@acm.org>
parents:
17670
diff
changeset
|
49 current = current->wr_next; |
|
16385
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
50 } |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
51 } |
|
19306
a7bbac69c8ef
Use METH_O where possible (two functions). This does not lead to real
Fred Drake <fdrake@acm.org>
parents:
17670
diff
changeset
|
52 } |
|
a7bbac69c8ef
Use METH_O where possible (two functions). This does not lead to real
Fred Drake <fdrake@acm.org>
parents:
17670
diff
changeset
|
53 else { |
|
a7bbac69c8ef
Use METH_O where possible (two functions). This does not lead to real
Fred Drake <fdrake@acm.org>
parents:
17670
diff
changeset
|
54 result = PyList_New(0); |
|
16385
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
55 } |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
56 return result; |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
57 } |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
58 |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
59 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
20634
diff
changeset
|
60 PyDoc_STRVAR(weakref_proxy__doc__, |
|
16659
deec6fa80471
Move docstrings out of function table to constants defined near the
Fred Drake <fdrake@acm.org>
parents:
16434
diff
changeset
|
61 "proxy(object[, callback]) -- create a proxy object that weakly\n" |
|
deec6fa80471
Move docstrings out of function table to constants defined near the
Fred Drake <fdrake@acm.org>
parents:
16434
diff
changeset
|
62 "references 'object'. 'callback', if given, is called with a\n" |
|
24503
4897e29e19cc
Fix ref(), proxy() docstrings, based on comments from David Abrahams.
Fred Drake <fdrake@acm.org>
parents:
24471
diff
changeset
|
63 "reference to the proxy when 'object' is about to be finalized."); |
|
16659
deec6fa80471
Move docstrings out of function table to constants defined near the
Fred Drake <fdrake@acm.org>
parents:
16434
diff
changeset
|
64 |
|
16385
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
65 static PyObject * |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
66 weakref_proxy(PyObject *self, PyObject *args) |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
67 { |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
68 PyObject *object; |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
69 PyObject *callback = NULL; |
|
20285
ccb7abc714ed
Adjust the _weakref module to use the public API for the weak reference
Fred Drake <fdrake@acm.org>
parents:
19581
diff
changeset
|
70 PyObject *result = NULL; |
|
16385
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
71 |
|
20634
899bebc89047
Convert the ref() and proxy() implementations to use the new
Fred Drake <fdrake@acm.org>
parents:
20285
diff
changeset
|
72 if (PyArg_UnpackTuple(args, "proxy", 1, 2, &object, &callback)) { |
|
20285
ccb7abc714ed
Adjust the _weakref module to use the public API for the weak reference
Fred Drake <fdrake@acm.org>
parents:
19581
diff
changeset
|
73 result = PyWeakref_NewProxy(object, callback); |
|
16385
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
74 } |
|
20285
ccb7abc714ed
Adjust the _weakref module to use the public API for the weak reference
Fred Drake <fdrake@acm.org>
parents:
19581
diff
changeset
|
75 return result; |
|
16385
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
76 } |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
77 |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
78 |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
79 static PyMethodDef |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
80 weakref_functions[] = { |
|
19306
a7bbac69c8ef
Use METH_O where possible (two functions). This does not lead to real
Fred Drake <fdrake@acm.org>
parents:
17670
diff
changeset
|
81 {"getweakrefcount", weakref_getweakrefcount, METH_O, |
|
16659
deec6fa80471
Move docstrings out of function table to constants defined near the
Fred Drake <fdrake@acm.org>
parents:
16434
diff
changeset
|
82 weakref_getweakrefcount__doc__}, |
|
19306
a7bbac69c8ef
Use METH_O where possible (two functions). This does not lead to real
Fred Drake <fdrake@acm.org>
parents:
17670
diff
changeset
|
83 {"getweakrefs", weakref_getweakrefs, METH_O, |
|
16659
deec6fa80471
Move docstrings out of function table to constants defined near the
Fred Drake <fdrake@acm.org>
parents:
16434
diff
changeset
|
84 weakref_getweakrefs__doc__}, |
|
deec6fa80471
Move docstrings out of function table to constants defined near the
Fred Drake <fdrake@acm.org>
parents:
16434
diff
changeset
|
85 {"proxy", weakref_proxy, METH_VARARGS, |
|
deec6fa80471
Move docstrings out of function table to constants defined near the
Fred Drake <fdrake@acm.org>
parents:
16434
diff
changeset
|
86 weakref_proxy__doc__}, |
|
16385
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
87 {NULL, NULL, 0, NULL} |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
88 }; |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
89 |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
90 |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
91 static struct PyModuleDef weakrefmodule = { |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
92 PyModuleDef_HEAD_INIT, |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
93 "_weakref", |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
94 "Weak-reference support module.", |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
95 -1, |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
96 weakref_functions, |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
97 NULL, |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
98 NULL, |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
99 NULL, |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
100 NULL |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
101 }; |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
102 |
|
24471
f66b3a3509c7
Excise DL_EXPORT/DL_IMPORT from Modules/*. Required adding a prototype
Mark Hammond <mhammond@skippinet.com.au>
parents:
23832
diff
changeset
|
103 PyMODINIT_FUNC |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
104 PyInit__weakref(void) |
|
16385
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
105 { |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
106 PyObject *m; |
|
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
107 |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
108 m = PyModule_Create(&weakrefmodule); |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
109 |
|
16385
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
110 if (m != NULL) { |
|
20285
ccb7abc714ed
Adjust the _weakref module to use the public API for the weak reference
Fred Drake <fdrake@acm.org>
parents:
19581
diff
changeset
|
111 Py_INCREF(&_PyWeakref_RefType); |
|
32472
4383db77b19a
Make weak references subclassable:
Fred Drake <fdrake@acm.org>
parents:
24503
diff
changeset
|
112 PyModule_AddObject(m, "ref", |
|
4383db77b19a
Make weak references subclassable:
Fred Drake <fdrake@acm.org>
parents:
24503
diff
changeset
|
113 (PyObject *) &_PyWeakref_RefType); |
|
4383db77b19a
Make weak references subclassable:
Fred Drake <fdrake@acm.org>
parents:
24503
diff
changeset
|
114 Py_INCREF(&_PyWeakref_RefType); |
|
16385
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
115 PyModule_AddObject(m, "ReferenceType", |
|
20285
ccb7abc714ed
Adjust the _weakref module to use the public API for the weak reference
Fred Drake <fdrake@acm.org>
parents:
19581
diff
changeset
|
116 (PyObject *) &_PyWeakref_RefType); |
|
ccb7abc714ed
Adjust the _weakref module to use the public API for the weak reference
Fred Drake <fdrake@acm.org>
parents:
19581
diff
changeset
|
117 Py_INCREF(&_PyWeakref_ProxyType); |
|
16385
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
118 PyModule_AddObject(m, "ProxyType", |
|
20285
ccb7abc714ed
Adjust the _weakref module to use the public API for the weak reference
Fred Drake <fdrake@acm.org>
parents:
19581
diff
changeset
|
119 (PyObject *) &_PyWeakref_ProxyType); |
|
ccb7abc714ed
Adjust the _weakref module to use the public API for the weak reference
Fred Drake <fdrake@acm.org>
parents:
19581
diff
changeset
|
120 Py_INCREF(&_PyWeakref_CallableProxyType); |
|
16385
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
121 PyModule_AddObject(m, "CallableProxyType", |
|
20285
ccb7abc714ed
Adjust the _weakref module to use the public API for the weak reference
Fred Drake <fdrake@acm.org>
parents:
19581
diff
changeset
|
122 (PyObject *) &_PyWeakref_CallableProxyType); |
|
16385
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
123 } |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
124 return m; |
|
16385
1fb6672b20ef
PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
125 } |
