Skip to content

Commit 80957fb

Browse files
author
guido
committed
Added __members__ secret attribute
git-svn-id: http://svn.python.org/projects/python/trunk@2559 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent ec7bc65 commit 80957fb

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Python/structmember.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,29 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2828

2929
#include "structmember.h"
3030

31+
static object *
32+
listmembers(mlist)
33+
struct memberlist *mlist;
34+
{
35+
int i, n;
36+
object *v;
37+
for (n = 0; mlist[n].name != NULL; n++)
38+
;
39+
v = newlistobject(n);
40+
if (v != NULL) {
41+
for (i = 0; i < n; i++)
42+
setlistitem(v, i, newstringobject(mlist[i].name));
43+
if (err_occurred()) {
44+
DECREF(v);
45+
v = NULL;
46+
}
47+
else {
48+
sortlist(v);
49+
}
50+
}
51+
return v;
52+
}
53+
3154
object *
3255
getmember(addr, mlist, name)
3356
char *addr;
@@ -36,6 +59,8 @@ getmember(addr, mlist, name)
3659
{
3760
struct memberlist *l;
3861

62+
if (strcmp(name, "__members__") == 0)
63+
return listmembers(mlist);
3964
for (l = mlist; l->name != NULL; l++) {
4065
if (strcmp(l->name, name) == 0) {
4166
object *v;

0 commit comments

Comments
 (0)