Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f59677a

Browse files
committed
The rest of patch 1549670 by Jiwon, making the compiler test pass.
This removes some bogus debug stuff Jiwon accidentally left in last time.
1 parent 29602e4 commit f59677a

2 files changed

Lines changed: 32 additions & 54 deletions

File tree

Lib/compiler/transformer.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -831,17 +831,11 @@ def com_arglist(self, nodelist):
831831
i = i + 3
832832
else: # no vararg
833833
assert node[0] == token.COMMA
834-
i += 1
835-
#elif node[0] == token.COMMA:
836-
# i += 1
837-
# kwonlyargs, skip = self.keywordonlyargs(nodelist[i:])
838-
# i += skip
839-
if nodelist[i][0] == token.NAME:
834+
i += 2
835+
if i < len(nodelist) and nodelist[i][0] == token.NAME:
840836
kwonlyargs, skip = self.keywordonlyargs(nodelist[i:])
841837
i += skip
842838

843-
print "kwonlyargs:", kwonlyargs
844-
845839
if i < len(nodelist):
846840
# should be DOUBLESTAR
847841
t = nodelist[i][0]
@@ -869,7 +863,6 @@ def com_arglist(self, nodelist):
869863
# skip the comma
870864
i = i + 1
871865

872-
print "names:", names, "defaults:", defaults, "kwonlyargs:", kwonlyargs, "flags:", flags
873866
return names, defaults, kwonlyargs, flags
874867

875868
def com_fpdef(self, node):

Lib/test/test_compiler.py

Lines changed: 30 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -19,51 +19,36 @@ def testCompileLibrary(self):
1919
libdir = os.path.dirname(unittest.__file__)
2020
testdir = os.path.dirname(test.test_support.__file__)
2121

22-
## for dir in [libdir, testdir]:
23-
## for basename in os.listdir(dir):
24-
## # Print still working message since this test can be really slow
25-
## if next_time <= time.time():
26-
## next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL
27-
## print >>sys.__stdout__, \
28-
## ' testCompileLibrary still working, be patient...'
29-
## sys.__stdout__.flush()
30-
##
31-
## if not basename.endswith(".py"):
32-
## continue
33-
## if not TEST_ALL and random() < 0.98:
34-
## continue
35-
## path = os.path.join(dir, basename)
36-
## if test.test_support.verbose:
37-
## print "compiling", path
38-
## f = open(path, "U")
39-
## buf = f.read()
40-
## f.close()
41-
## if "badsyntax" in basename or "bad_coding" in basename:
42-
## self.assertRaises(SyntaxError, compiler.compile,
43-
## buf, basename, "exec")
44-
## else:
45-
## try:
46-
## compiler.compile(buf, basename, "exec")
47-
## except Exception, e:
48-
## args = list(e.args)
49-
## args[0] += "[in file %s]" % basename
50-
## e.args = tuple(args)
51-
## raise
52-
53-
path = "/home/jiwon/p3yk/Lib/test/test_keywordonlyarg.py"
54-
if test.test_support.verbose:
55-
print "compiling", path
56-
f = open(path, "U")
57-
buf = f.read()
58-
f.close()
59-
#try:
60-
compiler.compile(buf, "test_keywordonlyarg.py", "exec")
61-
#except Exception, e:
62-
# args = list(e.args)
63-
# args[0] += "[in file %s]" % path
64-
# e.args = tuple(args)
65-
# raise
66-
22+
for dir in [libdir, testdir]:
23+
for basename in os.listdir(dir):
24+
# Print still working message since this test can be really slow
25+
if next_time <= time.time():
26+
next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL
27+
print >>sys.__stdout__, \
28+
' testCompileLibrary still working, be patient...'
29+
sys.__stdout__.flush()
30+
31+
if not basename.endswith(".py"):
32+
continue
33+
if not TEST_ALL and random() < 0.98:
34+
continue
35+
path = os.path.join(dir, basename)
36+
if test.test_support.verbose:
37+
print "compiling", path
38+
f = open(path, "U")
39+
buf = f.read()
40+
f.close()
41+
if "badsyntax" in basename or "bad_coding" in basename:
42+
self.assertRaises(SyntaxError, compiler.compile,
43+
buf, basename, "exec")
44+
else:
45+
try:
46+
compiler.compile(buf, basename, "exec")
47+
except Exception, e:
48+
args = list(e.args)
49+
args[0] += "[in file %s]" % basename
50+
e.args = tuple(args)
51+
raise
6752

6853
def testNewClassSyntax(self):
6954
compiler.compile("class foo():pass\n\n","<string>","exec")

0 commit comments

Comments
 (0)