Commits

Georg Brandl committed 29ea507

Make _fields attr for no fields consistent with _attributes attr.

Comments (0)

Files changed (3)

Lib/test/test_ast.py

         self.assertEquals(x.right, 3)
         self.assertEquals(x.lineno, 0)
 
+        # this used to fail because Sub._fields was None
+        x = _ast.Sub()
+
 
 def test_main():
     test_support.run_unittest(AST_Tests)
 {
     PyObject *fnames, *result;
     int i;
-    if (num_fields) {
-        fnames = PyTuple_New(num_fields);
-        if (!fnames) return NULL;
-    } else {
-        fnames = Py_None;
-        Py_INCREF(Py_None);
-    }
-    for(i=0; i < num_fields; i++) {
+    fnames = PyTuple_New(num_fields);
+    if (!fnames) return NULL;
+    for (i = 0; i < num_fields; i++) {
         PyObject *field = PyString_FromString(fields[i]);
         if (!field) {
             Py_DECREF(fnames);

Python/Python-ast.c

 {
     PyObject *fnames, *result;
     int i;
-    if (num_fields) {
-        fnames = PyTuple_New(num_fields);
-        if (!fnames) return NULL;
-    } else {
-        fnames = Py_None;
-        Py_INCREF(Py_None);
-    }
-    for(i=0; i < num_fields; i++) {
+    fnames = PyTuple_New(num_fields);
+    if (!fnames) return NULL;
+    for (i = 0; i < num_fields; i++) {
         PyObject *field = PyString_FromString(fields[i]);
         if (!field) {
             Py_DECREF(fnames);