Commit d6a9e84
committed
Committing PEP 232, function attribute feature, approved by Guido.
Closes SF patch python#103123.
funcobject.h:
PyFunctionObject: add the func_dict slot.
funcobject.c:
PyFunction_New(): Initialize the func_dict slot to NULL.
func_getattr(): Rename to func_getattro() and change the
signature. It's more efficient to use attro methods and dig the C
string out than it is to re-convert a C string to a PyString.
Also, add support for getting the __dict__ (a.k.a. func_dict)
attribute, and for getting an arbitrary function attribute.
func_setattr(): Rename to func_setattro() and change the signature
for the same reason. Also add support for setting __dict__
(a.k.a. func_dict) and any arbitrary function attribute.
func_dealloc(): Be sure to DECREF the func_dict slot.
func_traverse(): Be sure to traverse func_dict too.
PyFunction_Type: make the necessary func_?etattro() changes.
classobject.c:
instancemethod_memberlist: Add __dict__
instancemethod_setattro(): New method to set arbitrary attributes
on methods (really the underlying im_func). Raise TypeError when
the instance is bound or when you're trying to set one of the
reserved im_* attributes.
instancemethod_getattr(): Renamed to instancemethod_getattro()
since that's what it really is. Also, added support fo getting
arbitrary attributes through the im_func.
PyMethod_Type: Do the ?etattr{,o} dance.1 parent 4a420a0 commit d6a9e84
3 files changed
Lines changed: 114 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1693 | 1693 | | |
1694 | 1694 | | |
1695 | 1695 | | |
| 1696 | + | |
1696 | 1697 | | |
1697 | 1698 | | |
1698 | 1699 | | |
| 1700 | + | |
| 1701 | + | |
| 1702 | + | |
| 1703 | + | |
| 1704 | + | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
| 1710 | + | |
| 1711 | + | |
| 1712 | + | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
1699 | 1724 | | |
1700 | | - | |
| 1725 | + | |
1701 | 1726 | | |
| 1727 | + | |
1702 | 1728 | | |
1703 | 1729 | | |
1704 | 1730 | | |
| |||
1712 | 1738 | | |
1713 | 1739 | | |
1714 | 1740 | | |
1715 | | - | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
1716 | 1750 | | |
1717 | 1751 | | |
1718 | 1752 | | |
| |||
1832 | 1866 | | |
1833 | 1867 | | |
1834 | 1868 | | |
1835 | | - | |
1836 | | - | |
| 1869 | + | |
| 1870 | + | |
1837 | 1871 | | |
1838 | 1872 | | |
1839 | 1873 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
| 35 | + | |
| 36 | + | |
34 | 37 | | |
35 | 38 | | |
36 | 39 | | |
| |||
102 | 105 | | |
103 | 106 | | |
104 | 107 | | |
105 | | - | |
| 108 | + | |
106 | 109 | | |
107 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
108 | 114 | | |
109 | 115 | | |
110 | 116 | | |
111 | 117 | | |
112 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
113 | 142 | | |
114 | 143 | | |
115 | 144 | | |
116 | | - | |
| 145 | + | |
117 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
118 | 150 | | |
119 | 151 | | |
120 | 152 | | |
121 | 153 | | |
122 | 154 | | |
123 | | - | |
| 155 | + | |
124 | 156 | | |
125 | 157 | | |
126 | 158 | | |
127 | 159 | | |
128 | 160 | | |
129 | 161 | | |
130 | 162 | | |
131 | | - | |
| 163 | + | |
132 | 164 | | |
133 | 165 | | |
134 | 166 | | |
| |||
138 | 170 | | |
139 | 171 | | |
140 | 172 | | |
141 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
142 | 200 | | |
143 | 201 | | |
144 | 202 | | |
| |||
150 | 208 | | |
151 | 209 | | |
152 | 210 | | |
| 211 | + | |
153 | 212 | | |
154 | 213 | | |
155 | 214 | | |
| |||
227 | 286 | | |
228 | 287 | | |
229 | 288 | | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
230 | 294 | | |
231 | 295 | | |
232 | 296 | | |
| |||
238 | 302 | | |
239 | 303 | | |
240 | 304 | | |
241 | | - | |
242 | | - | |
| 305 | + | |
| 306 | + | |
243 | 307 | | |
244 | 308 | | |
245 | 309 | | |
| |||
248 | 312 | | |
249 | 313 | | |
250 | 314 | | |
251 | | - | |
252 | | - | |
| 315 | + | |
| 316 | + | |
253 | 317 | | |
254 | 318 | | |
255 | 319 | | |
| |||
0 commit comments