compiler module bug?

Brian Blais bblais at bryant.edu
Sun Oct 21 18:36:46 CEST 2007


Hello,

I am experiencing a problem with the compiler module.  Is this a bug,  
or am I doing something wrong?

so I have the following code:

from compiler import parse, parseFile

filename='blah.py'

if False:  # turn this to false, to get it to work
     ast = parse(open(filename).read())   # this line gives a syntax  
error
else:
     ast = parseFile(filename)  # this line works


print ast


the documentation, here http://docs.python.org/lib/module- 
compiler.html  says that the two lines with parse and parseFile are  
equivalent.

the file I am trying to parse is simply:

def main():

     a=10

     # comment at the end of the file




it seems like a comment at the end breaks the parse command, but not  
parseFile.  Is this reproducible by others?

am I doing something wrong?

		thanks,

			Brian Blais



-- 
Brian Blais
bblais at bryant.edu
http://web.bryant.edu/~bblais



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20071021/4a2ae09f/attachment.html>


More information about the Python-list mailing list