[Python-checkins] python/nondist/sandbox/ast test.py,1.5,1.6
jhylton@users.sourceforge.net
jhylton@users.sourceforge.net
Fri, 05 Jul 2002 12:58:11 -0700
Update of /cvsroot/python/python/nondist/sandbox/ast
In directory usw-pr-cvs1:/tmp/cvs-serv30046
Modified Files:
test.py
Log Message:
fiddle test script to print stmt that caused error.
Index: test.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/ast/test.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** test.py 30 May 2002 20:09:14 -0000 1.5
--- test.py 5 Jul 2002 19:58:09 -0000 1.6
***************
*** 1,5 ****
import ast
! ast.transform("""# let's start with a whole bunch of argument lists
! def f(x): pass
def f(x, y): pass
def f(x, y,): pass
--- 1,27 ----
import ast
!
! NEWLINE = "\n"
!
! def transform(s):
! try:
! ast.transform(s)
! except:
! print s
! raise
!
! def main():
! multi = None
! for line in stmts.split(NEWLINE):
! if not line:
! if multi:
! multi.append('')
! transform(NEWLINE.join(multi))
! multi = []
! if multi is None:
! transform(line)
! else:
! multi.append(line)
!
! stmts = """def f(x): pass
def f(x, y): pass
def f(x, y,): pass
***************
*** 54,60 ****
--- 76,110 ----
import a.b
from a.b import c
+ class C: pass
+ class C(A): pass
+ class C(A, B): pass
+ class C(A, B, (C,)): pass
+ d = {}
+ d = {1:2}
+ d = {1:2,}
+ d = {1:2, 3:4,}
+ [1,2,3,4]
+ [x for x in x if x if x for y in y if y]
+ [x for x in x]
+ obj.attr
+ l[...]
+ x[0]
+ x[:]
+ x[1:]
+ x[:1]
+ x[::]
+ x[1:1]
+ x[1::]
+ x[:1:]
+ x[::1]
+ x[1:1:]
+ x[1:1:1]
+ x[1:2,2:3]
+ # put all the multi-line stmts here
+
if a:
print b
a
+
if a:
a
***************
*** 62,69 ****
--- 112,121 ----
print b
c
+
if a:
a
elif b:
b
+
if a == 1:
a
***************
*** 76,96 ****
--- 128,154 ----
else:
pass
+
while 1:
1
2
+
while 1:
pass
+
while 1 and 2:
pass
else:
1
+
try:
1
finally:
2
+
try:
a + b
except:
pass
+
try:
a + b
***************
*** 99,102 ****
--- 157,161 ----
except:
pass
+
try:
a + b
***************
*** 105,108 ****
--- 164,168 ----
except:
pass
+
try:
a + b
***************
*** 111,137 ****
except:
pass
! class C: pass
! class C(A): pass
! class C(A, B): pass
! class C(A, B, (C,)): pass
! d = {}
! d = {1:2}
! d = {1:2,}
! d = {1:2, 3:4,}
! [1,2,3,4]
! [x for x in x if x if x for y in y if y]
! [x for x in x]
! obj.attr
! x[0]
! x[:]
! x[1:]
! x[:1]
! x[::]
! x[1:1]
! x[1::]
! x[:1:]
! x[::1]
! x[1:1:]
! x[1:1:1]
! x[1:2,2:3]
! """)
--- 171,176 ----
except:
pass
! """
!
! if __name__ == "__main__":
! main()