[Python-checkins] python/dist/src/Parser asdl_c.py,2.1,2.2

nnorwitz@users.sourceforge.net nnorwitz at users.sourceforge.net
Sun Oct 23 20:59:20 CEST 2005


Update of /cvsroot/python/python/dist/src/Parser
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23703/Parser

Modified Files:
	asdl_c.py 
Log Message:
Use PyErr_NoMemory() instead of rolling our own.
Get rid of "int i" unused warnings from Python-ast.c which we are generating.


Index: asdl_c.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Parser/asdl_c.py,v
retrieving revision 2.1
retrieving revision 2.2
diff -u -d -r2.1 -r2.2
--- asdl_c.py	20 Oct 2005 19:59:24 -0000	2.1
+++ asdl_c.py	23 Oct 2005 18:59:17 -0000	2.2
@@ -282,7 +282,7 @@
 
         emit("p = (%s)malloc(sizeof(*p));" % ctype, 1)
         emit("if (!p) {", 1)
-        emit("PyErr_SetString(PyExc_MemoryError, \"no memory\");", 2)
+        emit("PyErr_NoMemory();", 2)
         emit("return NULL;", 2)
         emit("}", 1)
         if union:
@@ -491,9 +491,8 @@
         self.emit("marshal_write_%s(PyObject **buf, int *off, %s o)" %
                   (name, ctype), 0)
         self.emit("{", 0)
-        # XXX: add declaration of "int i;" properly
-        if has_seq or True:
-            self.emit("int i;", 1) # XXX only need it for sequences
+        if has_seq:
+            self.emit("int i;", 1)
 
     def func_end(self):
         self.emit("return 1;", 1)
@@ -501,8 +500,7 @@
         self.emit("", 0)
     
     def visitSum(self, sum, name):
-        has_seq = has_sequence(sum.types, False)
-        self.func_begin(name, has_seq)
+        self.func_begin(name, has_sequence(sum.types, False))
         simple = is_simple(sum)
         if simple:
             self.emit("switch (o) {", 1)
@@ -515,7 +513,7 @@
         self.func_end()
 
     def visitProduct(self, prod, name):
-        self.func_begin(name, find_sequence(prod.fields, True))
+        self.func_begin(name, find_sequence(prod.fields, False))
         for field in prod.fields:
             self.visitField(field, name, 1, 1)
         self.func_end()



More information about the Python-checkins mailing list