mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
pelican_open: don't raise IndexError on empty files
If the file is empty, content[0] raises IndexError.
This commit is contained in:
parent
6232241ef1
commit
5d860471ac
1 changed files with 1 additions and 1 deletions
|
|
@ -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:
|
with codecs.open(filename, mode, encoding='utf-8') as infile:
|
||||||
content = infile.read()
|
content = infile.read()
|
||||||
if content[0] == codecs.BOM_UTF8.decode('utf8'):
|
if content[:1] == codecs.BOM_UTF8.decode('utf8'):
|
||||||
content = content[1:]
|
content = content[1:]
|
||||||
if strip_crs:
|
if strip_crs:
|
||||||
content = content.replace('\r\n', '\n')
|
content = content.replace('\r\n', '\n')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue