En Sun, 21 Oct 2007 14:33:00 -0300, Brian Blais <[EMAIL PROTECTED]> escribió:
> On Oct 21, 2007, at Oct 21:1:15 PM, Gabriel Genellina wrote: >> The comment itself is not a problem; but the last line in the >> source must >> end in a newline. > > then, even if it is known problem, the docs are wrong. the two > (parseFile(path) and parse(open(path).read())) are *not* the same: > one can handle a file which doesn't end in a newline, another one > can't handle the same file. Feel free to submit a bug report to http://bugs.python.org > Can one hack it like: > > filestr=open(filename).read() > filestr+="\n" The parseFile function does exactly that, along with this comment: # XXX The parser API tolerates files without a trailing newline, # but not strings without a trailing newline. Always add an extra # newline to the file contents, since we're going through the string # version of the API. The compile function in py_compile.py that I've menctioned earlier does the same but only when needed: f = open(file, 'U') codestring = f.read() f.close() if codestring and codestring[-1] != '\n': codestring = codestring + '\n' -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list