Mercurial > cpython-lru_cache-weakref
comparison Python/Python-ast.c @ 46204:29ea507fd998 legacy-trunk
Make _fields attr for no fields consistent with _attributes attr.
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Sun, 30 Mar 2008 19:00:49 +0000 |
| parents | 42c5d287a852 |
| children | 59d42e6d1885 |
comparison
equal
deleted
inserted
replaced
| 46203:f051e7a80acc | 46204:29ea507fd998 |
|---|---|
| 463 | 463 |
| 464 static PyTypeObject* make_type(char *type, PyTypeObject* base, char**fields, int num_fields) | 464 static PyTypeObject* make_type(char *type, PyTypeObject* base, char**fields, int num_fields) |
| 465 { | 465 { |
| 466 PyObject *fnames, *result; | 466 PyObject *fnames, *result; |
| 467 int i; | 467 int i; |
| 468 if (num_fields) { | 468 fnames = PyTuple_New(num_fields); |
| 469 fnames = PyTuple_New(num_fields); | 469 if (!fnames) return NULL; |
| 470 if (!fnames) return NULL; | 470 for (i = 0; i < num_fields; i++) { |
| 471 } else { | |
| 472 fnames = Py_None; | |
| 473 Py_INCREF(Py_None); | |
| 474 } | |
| 475 for(i=0; i < num_fields; i++) { | |
| 476 PyObject *field = PyString_FromString(fields[i]); | 471 PyObject *field = PyString_FromString(fields[i]); |
| 477 if (!field) { | 472 if (!field) { |
| 478 Py_DECREF(fnames); | 473 Py_DECREF(fnames); |
| 479 return NULL; | 474 return NULL; |
| 480 } | 475 } |
