Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 1 | /*********************************************************** |
Guido van Rossum | fd71b9e | 2000-06-30 23:50:40 +0000 | [diff] [blame] | 2 | Copyright (c) 2000, BeOpen.com. |
| 3 | Copyright (c) 1995-2000, Corporation for National Research Initiatives. |
| 4 | Copyright (c) 1990-1995, Stichting Mathematisch Centrum. |
| 5 | All rights reserved. |
Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 6 | |
Guido van Rossum | fd71b9e | 2000-06-30 23:50:40 +0000 | [diff] [blame] | 7 | See the file "Misc/COPYRIGHT" for information on usage and |
| 8 | redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 9 | ******************************************************************/ |
| 10 | |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 11 | /* Map C struct members to Python object attributes */ |
| 12 | |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 13 | #include "Python.h" |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 14 | |
| 15 | #include "structmember.h" |
| 16 | |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 17 | static PyObject * |
Guido van Rossum | 2f1d87e | 1991-10-20 20:24:14 +0000 | [diff] [blame] | 18 | listmembers(mlist) |
| 19 | struct memberlist *mlist; |
| 20 | { |
| 21 | int i, n; |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 22 | PyObject *v; |
Guido van Rossum | 2f1d87e | 1991-10-20 20:24:14 +0000 | [diff] [blame] | 23 | for (n = 0; mlist[n].name != NULL; n++) |
| 24 | ; |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 25 | v = PyList_New(n); |
Guido van Rossum | 2f1d87e | 1991-10-20 20:24:14 +0000 | [diff] [blame] | 26 | if (v != NULL) { |
| 27 | for (i = 0; i < n; i++) |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 28 | PyList_SetItem(v, i, |
| 29 | PyString_FromString(mlist[i].name)); |
| 30 | if (PyErr_Occurred()) { |
| 31 | Py_DECREF(v); |
Guido van Rossum | 2f1d87e | 1991-10-20 20:24:14 +0000 | [diff] [blame] | 32 | v = NULL; |
| 33 | } |
| 34 | else { |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 35 | PyList_Sort(v); |
Guido van Rossum | 2f1d87e | 1991-10-20 20:24:14 +0000 | [diff] [blame] | 36 | } |
| 37 | } |
| 38 | return v; |
| 39 | } |
| 40 | |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 41 | PyObject * |
| 42 | PyMember_Get(addr, mlist, name) |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 43 | char *addr; |
| 44 | struct memberlist *mlist; |
| 45 | char *name; |
| 46 | { |
| 47 | struct memberlist *l; |
| 48 | |
Guido van Rossum | 2f1d87e | 1991-10-20 20:24:14 +0000 | [diff] [blame] | 49 | if (strcmp(name, "__members__") == 0) |
| 50 | return listmembers(mlist); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 51 | for (l = mlist; l->name != NULL; l++) { |
| 52 | if (strcmp(l->name, name) == 0) { |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 53 | PyObject *v; |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 54 | addr += l->offset; |
| 55 | switch (l->type) { |
Guido van Rossum | ab2490a | 1992-06-03 17:07:23 +0000 | [diff] [blame] | 56 | case T_BYTE: |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 57 | v = PyInt_FromLong((long) |
Guido van Rossum | ab2490a | 1992-06-03 17:07:23 +0000 | [diff] [blame] | 58 | (((*(char*)addr & 0xff) |
| 59 | ^ 0x80) - 0x80)); |
| 60 | break; |
| 61 | case T_UBYTE: |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 62 | v = PyInt_FromLong((long) *(char*)addr & 0xff); |
Guido van Rossum | ab2490a | 1992-06-03 17:07:23 +0000 | [diff] [blame] | 63 | break; |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 64 | case T_SHORT: |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 65 | v = PyInt_FromLong((long) *(short*)addr); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 66 | break; |
Guido van Rossum | ab2490a | 1992-06-03 17:07:23 +0000 | [diff] [blame] | 67 | case T_USHORT: |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 68 | v = PyInt_FromLong((long) |
Guido van Rossum | ab2490a | 1992-06-03 17:07:23 +0000 | [diff] [blame] | 69 | *(unsigned short*)addr); |
| 70 | break; |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 71 | case T_INT: |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 72 | v = PyInt_FromLong((long) *(int*)addr); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 73 | break; |
Guido van Rossum | ab2490a | 1992-06-03 17:07:23 +0000 | [diff] [blame] | 74 | case T_UINT: |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 75 | v = PyInt_FromLong((long) |
| 76 | *(unsigned int*)addr); |
Guido van Rossum | ab2490a | 1992-06-03 17:07:23 +0000 | [diff] [blame] | 77 | break; |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 78 | case T_LONG: |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 79 | v = PyInt_FromLong(*(long*)addr); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 80 | break; |
Guido van Rossum | ab2490a | 1992-06-03 17:07:23 +0000 | [diff] [blame] | 81 | case T_ULONG: |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 82 | v = PyLong_FromDouble((double) |
Guido van Rossum | ab2490a | 1992-06-03 17:07:23 +0000 | [diff] [blame] | 83 | *(unsigned long*)addr); |
| 84 | break; |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 85 | case T_FLOAT: |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 86 | v = PyFloat_FromDouble((double)*(float*)addr); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 87 | break; |
| 88 | case T_DOUBLE: |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 89 | v = PyFloat_FromDouble(*(double*)addr); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 90 | break; |
| 91 | case T_STRING: |
| 92 | if (*(char**)addr == NULL) { |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 93 | Py_INCREF(Py_None); |
| 94 | v = Py_None; |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 95 | } |
| 96 | else |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 97 | v = PyString_FromString(*(char**)addr); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 98 | break; |
Jack Jansen | 599f0d1 | 1994-12-14 13:04:05 +0000 | [diff] [blame] | 99 | case T_STRING_INPLACE: |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 100 | v = PyString_FromString((char*)addr); |
Jack Jansen | 599f0d1 | 1994-12-14 13:04:05 +0000 | [diff] [blame] | 101 | break; |
| 102 | #ifdef macintosh |
| 103 | case T_PSTRING: |
| 104 | if (*(char**)addr == NULL) { |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 105 | Py_INCREF(Py_None); |
| 106 | v = Py_None; |
Jack Jansen | 599f0d1 | 1994-12-14 13:04:05 +0000 | [diff] [blame] | 107 | } |
| 108 | else |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 109 | v = PyString_FromStringAndSize( |
| 110 | (*(char**)addr)+1, |
| 111 | **(unsigned char**)addr); |
Jack Jansen | 599f0d1 | 1994-12-14 13:04:05 +0000 | [diff] [blame] | 112 | break; |
| 113 | case T_PSTRING_INPLACE: |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 114 | v = PyString_FromStringAndSize( |
| 115 | ((char*)addr)+1, |
| 116 | *(unsigned char*)addr); |
Jack Jansen | 599f0d1 | 1994-12-14 13:04:05 +0000 | [diff] [blame] | 117 | break; |
| 118 | #endif /* macintosh */ |
Guido van Rossum | ab2490a | 1992-06-03 17:07:23 +0000 | [diff] [blame] | 119 | case T_CHAR: |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 120 | v = PyString_FromStringAndSize((char*)addr, 1); |
Guido van Rossum | ab2490a | 1992-06-03 17:07:23 +0000 | [diff] [blame] | 121 | break; |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 122 | case T_OBJECT: |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 123 | v = *(PyObject **)addr; |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 124 | if (v == NULL) |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 125 | v = Py_None; |
| 126 | Py_INCREF(v); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 127 | break; |
| 128 | default: |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 129 | PyErr_SetString(PyExc_SystemError, |
| 130 | "bad memberlist type"); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 131 | v = NULL; |
| 132 | } |
| 133 | return v; |
| 134 | } |
| 135 | } |
| 136 | |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 137 | PyErr_SetString(PyExc_AttributeError, name); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 138 | return NULL; |
| 139 | } |
| 140 | |
| 141 | int |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 142 | PyMember_Set(addr, mlist, name, v) |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 143 | char *addr; |
| 144 | struct memberlist *mlist; |
| 145 | char *name; |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 146 | PyObject *v; |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 147 | { |
| 148 | struct memberlist *l; |
Guido van Rossum | adf0e43 | 1998-05-20 22:25:32 +0000 | [diff] [blame] | 149 | PyObject *oldv; |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 150 | |
| 151 | for (l = mlist; l->name != NULL; l++) { |
| 152 | if (strcmp(l->name, name) == 0) { |
Jack Jansen | 599f0d1 | 1994-12-14 13:04:05 +0000 | [diff] [blame] | 153 | #ifdef macintosh |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 154 | if (l->readonly || l->type == T_STRING || |
| 155 | l->type == T_PSTRING) |
| 156 | { |
Jack Jansen | 599f0d1 | 1994-12-14 13:04:05 +0000 | [diff] [blame] | 157 | #else |
| 158 | if (l->readonly || l->type == T_STRING ) { |
| 159 | #endif /* macintosh */ |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 160 | PyErr_SetString(PyExc_TypeError, |
| 161 | "readonly attribute"); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 162 | return -1; |
| 163 | } |
Guido van Rossum | 1d5735e | 1994-08-30 08:27:36 +0000 | [diff] [blame] | 164 | if (v == NULL && l->type != T_OBJECT) { |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 165 | PyErr_SetString(PyExc_TypeError, |
Guido van Rossum | 1d5735e | 1994-08-30 08:27:36 +0000 | [diff] [blame] | 166 | "can't delete numeric/char attribute"); |
| 167 | return -1; |
| 168 | } |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 169 | addr += l->offset; |
| 170 | switch (l->type) { |
Guido van Rossum | ab2490a | 1992-06-03 17:07:23 +0000 | [diff] [blame] | 171 | case T_BYTE: |
| 172 | case T_UBYTE: |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 173 | if (!PyInt_Check(v)) { |
| 174 | PyErr_BadArgument(); |
Guido van Rossum | ab2490a | 1992-06-03 17:07:23 +0000 | [diff] [blame] | 175 | return -1; |
| 176 | } |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 177 | *(char*)addr = (char) PyInt_AsLong(v); |
Guido van Rossum | ab2490a | 1992-06-03 17:07:23 +0000 | [diff] [blame] | 178 | break; |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 179 | case T_SHORT: |
Guido van Rossum | ab2490a | 1992-06-03 17:07:23 +0000 | [diff] [blame] | 180 | case T_USHORT: |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 181 | if (!PyInt_Check(v)) { |
| 182 | PyErr_BadArgument(); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 183 | return -1; |
| 184 | } |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 185 | *(short*)addr = (short) PyInt_AsLong(v); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 186 | break; |
Guido van Rossum | ab2490a | 1992-06-03 17:07:23 +0000 | [diff] [blame] | 187 | case T_UINT: |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 188 | case T_INT: |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 189 | if (!PyInt_Check(v)) { |
| 190 | PyErr_BadArgument(); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 191 | return -1; |
| 192 | } |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 193 | *(int*)addr = (int) PyInt_AsLong(v); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 194 | break; |
| 195 | case T_LONG: |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 196 | if (!PyInt_Check(v)) { |
| 197 | PyErr_BadArgument(); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 198 | return -1; |
| 199 | } |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 200 | *(long*)addr = PyInt_AsLong(v); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 201 | break; |
Guido van Rossum | ab2490a | 1992-06-03 17:07:23 +0000 | [diff] [blame] | 202 | case T_ULONG: |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 203 | if (PyInt_Check(v)) |
| 204 | *(long*)addr = PyInt_AsLong(v); |
| 205 | else if (PyLong_Check(v)) |
| 206 | *(long*)addr = PyLong_AsLong(v); |
Guido van Rossum | ab2490a | 1992-06-03 17:07:23 +0000 | [diff] [blame] | 207 | else { |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 208 | PyErr_BadArgument(); |
Guido van Rossum | ab2490a | 1992-06-03 17:07:23 +0000 | [diff] [blame] | 209 | return -1; |
| 210 | } |
| 211 | break; |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 212 | case T_FLOAT: |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 213 | if (PyInt_Check(v)) |
Guido van Rossum | 644a12b | 1997-04-09 19:24:53 +0000 | [diff] [blame] | 214 | *(float*)addr = |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 215 | (float) PyInt_AsLong(v); |
| 216 | else if (PyFloat_Check(v)) |
| 217 | *(float*)addr = |
| 218 | (float) PyFloat_AsDouble(v); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 219 | else { |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 220 | PyErr_BadArgument(); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 221 | return -1; |
| 222 | } |
| 223 | break; |
| 224 | case T_DOUBLE: |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 225 | if (PyInt_Check(v)) |
Guido van Rossum | 644a12b | 1997-04-09 19:24:53 +0000 | [diff] [blame] | 226 | *(double*)addr = |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 227 | (double) PyInt_AsLong(v); |
| 228 | else if (PyFloat_Check(v)) |
| 229 | *(double*)addr = PyFloat_AsDouble(v); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 230 | else { |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 231 | PyErr_BadArgument(); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 232 | return -1; |
| 233 | } |
| 234 | break; |
| 235 | case T_OBJECT: |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 236 | Py_XINCREF(v); |
Guido van Rossum | adf0e43 | 1998-05-20 22:25:32 +0000 | [diff] [blame] | 237 | oldv = *(PyObject **)addr; |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 238 | *(PyObject **)addr = v; |
Guido van Rossum | adf0e43 | 1998-05-20 22:25:32 +0000 | [diff] [blame] | 239 | Py_XDECREF(oldv); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 240 | break; |
Guido van Rossum | ab2490a | 1992-06-03 17:07:23 +0000 | [diff] [blame] | 241 | case T_CHAR: |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 242 | if (PyString_Check(v) && |
| 243 | PyString_Size(v) == 1) { |
Guido van Rossum | ab2490a | 1992-06-03 17:07:23 +0000 | [diff] [blame] | 244 | *(char*)addr = |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 245 | PyString_AsString(v)[0]; |
Guido van Rossum | ab2490a | 1992-06-03 17:07:23 +0000 | [diff] [blame] | 246 | } |
| 247 | else { |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 248 | PyErr_BadArgument(); |
Guido van Rossum | ab2490a | 1992-06-03 17:07:23 +0000 | [diff] [blame] | 249 | return -1; |
| 250 | } |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 251 | default: |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 252 | PyErr_SetString(PyExc_SystemError, |
| 253 | "bad memberlist type"); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 254 | return -1; |
| 255 | } |
| 256 | return 0; |
| 257 | } |
| 258 | } |
| 259 | |
Guido van Rossum | 79f25d9 | 1997-04-29 20:08:16 +0000 | [diff] [blame] | 260 | PyErr_SetString(PyExc_AttributeError, name); |
Guido van Rossum | 73531a3 | 1990-12-20 23:12:40 +0000 | [diff] [blame] | 261 | return -1; |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 262 | } |