ensure the last line has a trailing newline #8782

This commit is contained in:
Benjamin Peterson 2010-05-21 21:31:24 +00:00
parent dd59f1bf92
commit 266e454866
3 changed files with 17 additions and 0 deletions

View file

@ -133,6 +133,8 @@ def updatecache(filename, module_globals=None):
except IOError, msg:
## print '*** Cannot open', fullname, ':', msg
return []
if lines and not lines[-1].endswith('\n'):
lines[-1] += '\n'
size, mtime = stat.st_size, stat.st_mtime
cache[filename] = size, mtime, lines, fullname
return lines