1
0
Fork 0
forked from github/pelican

pelican_open: don't raise IndexError on empty files

If the file is empty, content[0] raises IndexError.
This commit is contained in:
Will Thompson 2016-08-11 07:46:53 +01:00
commit 5d860471ac

View file

@ -244,7 +244,7 @@ def pelican_open(filename, mode='rb', strip_crs=(sys.platform == 'win32')):
with codecs.open(filename, mode, encoding='utf-8') as infile:
content = infile.read()
if content[0] == codecs.BOM_UTF8.decode('utf8'):
if content[:1] == codecs.BOM_UTF8.decode('utf8'):
content = content[1:]
if strip_crs:
content = content.replace('\r\n', '\n')