]> granicus.if.org Git - python/commitdiff
The rest of patch 1549670 by Jiwon, making the compiler test pass.
authorGuido van Rossum <guido@python.org>
Wed, 22 Nov 2006 04:55:53 +0000 (04:55 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 22 Nov 2006 04:55:53 +0000 (04:55 +0000)
This removes some bogus debug stuff Jiwon accidentally left in last time.

Lib/compiler/transformer.py
Lib/test/test_compiler.py

index 7b1e31c2ecb0860b189eb127d1efafe6259b05ff..dc88222fa52da41f714886e6492595457a529793 100644 (file)
@@ -831,17 +831,11 @@ class Transformer:
                         i = i + 3
                     else: # no vararg
                         assert node[0] == token.COMMA
-                        i += 1
-                    #elif node[0] == token.COMMA:
-                    #    i += 1
-                    #    kwonlyargs, skip = self.keywordonlyargs(nodelist[i:])
-                    #    i += skip
-                    if nodelist[i][0] == token.NAME:
+                        i += 2
+                    if i < len(nodelist) and nodelist[i][0] == token.NAME:
                         kwonlyargs, skip = self.keywordonlyargs(nodelist[i:])
                         i += skip
 
-                print "kwonlyargs:", kwonlyargs
-
                 if i < len(nodelist):
                     # should be DOUBLESTAR
                     t = nodelist[i][0]
@@ -869,7 +863,6 @@ class Transformer:
             # skip the comma
             i = i + 1
 
-        print "names:", names, "defaults:", defaults, "kwonlyargs:", kwonlyargs, "flags:", flags
         return names, defaults, kwonlyargs, flags
 
     def com_fpdef(self, node):
index 3027de10cd8383cb393660a6b406f31ba9fa4e72..783a34c9a94b3ceacb51827ab56cb66138f619b9 100644 (file)
@@ -19,51 +19,36 @@ class CompilerTest(unittest.TestCase):
         libdir = os.path.dirname(unittest.__file__)
         testdir = os.path.dirname(test.test_support.__file__)
 
-##        for dir in [libdir, testdir]:
-##            for basename in os.listdir(dir):
-##                # Print still working message since this test can be really slow
-##                if next_time <= time.time():
-##                    next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL
-##                    print >>sys.__stdout__, \
-##                       '  testCompileLibrary still working, be patient...'
-##                    sys.__stdout__.flush()
-##
-##                if not basename.endswith(".py"):
-##                    continue
-##                if not TEST_ALL and random() < 0.98:
-##                    continue
-##                path = os.path.join(dir, basename)
-##                if test.test_support.verbose:
-##                    print "compiling", path
-##                f = open(path, "U")
-##                buf = f.read()
-##                f.close()
-##                if "badsyntax" in basename or "bad_coding" in basename:
-##                    self.assertRaises(SyntaxError, compiler.compile,
-##                                      buf, basename, "exec")
-##                else:
-##                    try:
-##                        compiler.compile(buf, basename, "exec")
-##                    except Exception, e:
-##                        args = list(e.args)
-##                        args[0] += "[in file %s]" % basename
-##                        e.args = tuple(args)
-##                        raise
-
-        path = "/home/jiwon/p3yk/Lib/test/test_keywordonlyarg.py"
-        if test.test_support.verbose:
-            print "compiling", path
-        f = open(path, "U")
-        buf = f.read()
-        f.close()
-        #try:
-        compiler.compile(buf, "test_keywordonlyarg.py", "exec")
-        #except Exception, e:
-        #    args = list(e.args)
-        #    args[0] += "[in file %s]" % path
-        #    e.args = tuple(args)
-        #    raise
-
+        for dir in [libdir, testdir]:
+            for basename in os.listdir(dir):
+                # Print still working message since this test can be really slow
+                if next_time <= time.time():
+                    next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL
+                    print >>sys.__stdout__, \
+                       '  testCompileLibrary still working, be patient...'
+                    sys.__stdout__.flush()
+
+                if not basename.endswith(".py"):
+                    continue
+                if not TEST_ALL and random() < 0.98:
+                    continue
+                path = os.path.join(dir, basename)
+                if test.test_support.verbose:
+                    print "compiling", path
+                f = open(path, "U")
+                buf = f.read()
+                f.close()
+                if "badsyntax" in basename or "bad_coding" in basename:
+                    self.assertRaises(SyntaxError, compiler.compile,
+                                      buf, basename, "exec")
+                else:
+                    try:
+                        compiler.compile(buf, basename, "exec")
+                    except Exception, e:
+                        args = list(e.args)
+                        args[0] += "[in file %s]" % basename
+                        e.args = tuple(args)
+                        raise
 
     def testNewClassSyntax(self):
         compiler.compile("class foo():pass\n\n","<string>","exec")