]> granicus.if.org Git - python/commitdiff
Make _fields attr for no fields consistent with _attributes attr.
authorGeorg Brandl <georg@python.org>
Sun, 30 Mar 2008 19:00:49 +0000 (19:00 +0000)
committerGeorg Brandl <georg@python.org>
Sun, 30 Mar 2008 19:00:49 +0000 (19:00 +0000)
Lib/test/test_ast.py
Parser/asdl_c.py
Python/Python-ast.c

index 4184bc62953e7dd15e0e497518c57cc4cb62e923..e068b0a1145f6554437a73ddd516e3c7f8d13188 100644 (file)
@@ -163,6 +163,9 @@ class AST_Tests(unittest.TestCase):
         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)
index 91196df35122b3069fada90790be4acaa6be60a5..08592bc4c4a643f1684557ca7c77397738d7648d 100755 (executable)
@@ -674,14 +674,9 @@ static PyTypeObject* make_type(char *type, PyTypeObject* base, char**fields, int
 {
     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);
index c44ce383c6859b6e58d4813da443ac5dfbbf6e10..d4734187de785dcf90435b32a91b91e9c0f12420 100644 (file)
@@ -465,14 +465,9 @@ static PyTypeObject* make_type(char *type, PyTypeObject* base, char**fields, int
 {
     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);