[Python-checkins] python/dist/src/Lib/test test_codeop.py,1.4,1.5 test_compile.py,1.15,1.16
gvanrossum@users.sourceforge.net
gvanrossum@users.sourceforge.net
Thu, 13 Feb 2003 14:08:29 -0800
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv26189/Lib/test
Modified Files:
test_codeop.py test_compile.py
Log Message:
- Finally fixed the bug in compile() and exec where a string ending
with an indented code block but no newline would raise SyntaxError.
This would have been a four-line change in parsetok.c... Except
codeop.py depends on this behavior, so a compilation flag had to be
invented that causes the tokenizer to revert to the old behavior;
this required extra changes to 2 .h files, 2 .c files, and 2 .py
files. (Fixes SF bug #501622.)
Index: test_codeop.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_codeop.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** test_codeop.py 23 Jul 2002 19:03:46 -0000 1.4
--- test_codeop.py 13 Feb 2003 22:07:54 -0000 1.5
***************
*** 6,10 ****
from test.test_support import run_unittest
! from codeop import compile_command
class CodeopTests(unittest.TestCase):
--- 6,10 ----
from test.test_support import run_unittest
! from codeop import compile_command, PyCF_DONT_IMPLY_DEDENT
class CodeopTests(unittest.TestCase):
***************
*** 12,16 ****
def assertValid(self, str, symbol='single'):
'''succeed iff str is a valid piece of code'''
! expected = compile(str, "<input>", symbol)
self.assertEquals( compile_command(str, "<input>", symbol), expected)
--- 12,16 ----
def assertValid(self, str, symbol='single'):
'''succeed iff str is a valid piece of code'''
! expected = compile(str, "<input>", symbol, PyCF_DONT_IMPLY_DEDENT)
self.assertEquals( compile_command(str, "<input>", symbol), expected)
***************
*** 43,47 ****
# special case
self.assertEquals(compile_command(""),
! compile("pass", "<input>", 'single'))
av("3**3","eval")
--- 43,48 ----
# special case
self.assertEquals(compile_command(""),
! compile("pass", "<input>", 'single',
! PyCF_DONT_IMPLY_DEDENT))
av("3**3","eval")
Index: test_compile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_compile.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** test_compile.py 12 Feb 2003 16:57:47 -0000 1.15
--- test_compile.py 13 Feb 2003 22:07:55 -0000 1.16
***************
*** 90,93 ****
--- 90,102 ----
expect_error("3-4e/21")
+ if verbose:
+ print "testing compile() of indented block w/o trailing newline"
+
+ s = """
+ if 1:
+ if 2:
+ pass"""
+ compile(s, "<string>", "exec")
+
if verbose: