##// END OF EJS Templates
heredoctest: 2to3 -w -f numliterals -f except -f print tests/heredoctest.py
Augie Fackler -
r25032:1db2127d default
parent child Browse files
Show More
@@ -1,18 +1,18 b''
1 import sys
1 import sys
2
2
3 globalvars = {}
3 globalvars = {}
4 lines = sys.stdin.readlines()
4 lines = sys.stdin.readlines()
5 while lines:
5 while lines:
6 l = lines.pop(0)
6 l = lines.pop(0)
7 if l.startswith('SALT'):
7 if l.startswith('SALT'):
8 print l[:-1]
8 print(l[:-1])
9 elif l.startswith('>>> '):
9 elif l.startswith('>>> '):
10 snippet = l[4:]
10 snippet = l[4:]
11 while lines and lines[0].startswith('... '):
11 while lines and lines[0].startswith('... '):
12 l = lines.pop(0)
12 l = lines.pop(0)
13 snippet += l[4:]
13 snippet += l[4:]
14 c = compile(snippet, '<heredoc>', 'single')
14 c = compile(snippet, '<heredoc>', 'single')
15 try:
15 try:
16 exec c in globalvars
16 exec(c, globalvars)
17 except Exception, inst:
17 except Exception as inst:
18 print repr(inst)
18 print(repr(inst))
General Comments 0
You need to be logged in to leave comments. Login now