mirror of
https://github.com/python/cpython.git
synced 2025-07-30 22:54:16 +00:00
Make _fields attr for no fields consistent with _attributes attr.
This commit is contained in:
parent
ebc8dedd19
commit
2c55c597fa
3 changed files with 9 additions and 16 deletions
|
@ -163,6 +163,9 @@ class AST_Tests(unittest.TestCase):
|
||||||
self.assertEquals(x.right, 3)
|
self.assertEquals(x.right, 3)
|
||||||
self.assertEquals(x.lineno, 0)
|
self.assertEquals(x.lineno, 0)
|
||||||
|
|
||||||
|
# this used to fail because Sub._fields was None
|
||||||
|
x = _ast.Sub()
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
test_support.run_unittest(AST_Tests)
|
test_support.run_unittest(AST_Tests)
|
||||||
|
|
|
@ -674,14 +674,9 @@ static PyTypeObject* make_type(char *type, PyTypeObject* base, char**fields, int
|
||||||
{
|
{
|
||||||
PyObject *fnames, *result;
|
PyObject *fnames, *result;
|
||||||
int i;
|
int i;
|
||||||
if (num_fields) {
|
fnames = PyTuple_New(num_fields);
|
||||||
fnames = PyTuple_New(num_fields);
|
if (!fnames) return NULL;
|
||||||
if (!fnames) return NULL;
|
for (i = 0; i < num_fields; i++) {
|
||||||
} else {
|
|
||||||
fnames = Py_None;
|
|
||||||
Py_INCREF(Py_None);
|
|
||||||
}
|
|
||||||
for(i=0; i < num_fields; i++) {
|
|
||||||
PyObject *field = PyString_FromString(fields[i]);
|
PyObject *field = PyString_FromString(fields[i]);
|
||||||
if (!field) {
|
if (!field) {
|
||||||
Py_DECREF(fnames);
|
Py_DECREF(fnames);
|
||||||
|
|
|
@ -465,14 +465,9 @@ static PyTypeObject* make_type(char *type, PyTypeObject* base, char**fields, int
|
||||||
{
|
{
|
||||||
PyObject *fnames, *result;
|
PyObject *fnames, *result;
|
||||||
int i;
|
int i;
|
||||||
if (num_fields) {
|
fnames = PyTuple_New(num_fields);
|
||||||
fnames = PyTuple_New(num_fields);
|
if (!fnames) return NULL;
|
||||||
if (!fnames) return NULL;
|
for (i = 0; i < num_fields; i++) {
|
||||||
} else {
|
|
||||||
fnames = Py_None;
|
|
||||||
Py_INCREF(Py_None);
|
|
||||||
}
|
|
||||||
for(i=0; i < num_fields; i++) {
|
|
||||||
PyObject *field = PyString_FromString(fields[i]);
|
PyObject *field = PyString_FromString(fields[i]);
|
||||||
if (!field) {
|
if (!field) {
|
||||||
Py_DECREF(fnames);
|
Py_DECREF(fnames);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue