[Python-checkins] python/dist/src/Lib code.py,1.21,1.22 codeop.py,1.5,1.6
gvanrossum@users.sourceforge.net
gvanrossum@users.sourceforge.net
Thu, 13 Feb 2003 14:08:27 -0800
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv26189/Lib
Modified Files:
code.py codeop.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: code.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/code.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** code.py 4 Apr 2002 22:55:58 -0000 1.21
--- code.py 13 Feb 2003 22:07:53 -0000 1.22
***************
*** 304,306 ****
if __name__ == '__main__':
! interact()
--- 304,307 ----
if __name__ == '__main__':
! import pdb
! pdb.run("interact()\n")
Index: codeop.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/codeop.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** codeop.py 17 Aug 2001 22:11:27 -0000 1.5
--- codeop.py 13 Feb 2003 22:07:54 -0000 1.6
***************
*** 64,67 ****
--- 64,69 ----
__all__ = ["compile_command", "Compile", "CommandCompiler"]
+ PyCF_DONT_IMPLY_DEDENT = 0x200 # Matches pythonrun.h
+
def _maybe_compile(compiler, source, filename, symbol):
# Check for source consisting of only blank lines and comments
***************
*** 104,107 ****
--- 106,112 ----
raise SyntaxError, err1
+ def _compile(source, filename, symbol):
+ return compile(source, filename, symbol, PyCF_DONT_IMPLY_DEDENT)
+
def compile_command(source, filename="<input>", symbol="single"):
r"""Compile a command and determine whether it is incomplete.
***************
*** 122,126 ****
malformed literals).
"""
! return _maybe_compile(compile, source, filename, symbol)
class Compile:
--- 127,131 ----
malformed literals).
"""
! return _maybe_compile(_compile, source, filename, symbol)
class Compile:
***************
*** 130,134 ****
with the statement in force."""
def __init__(self):
! self.flags = 0
def __call__(self, source, filename, symbol):
--- 135,139 ----
with the statement in force."""
def __init__(self):
! self.flags = PyCF_DONT_IMPLY_DEDENT
def __call__(self, source, filename, symbol):