Remove BOM bytes from recipes as well when compiling

This commit is contained in:
Kovid Goyal 2015-02-08 15:48:40 +05:30
parent 959acc1f28
commit 65ca3c490a

View File

@ -34,7 +34,7 @@ def compile_recipe(src):
enc = match.group(1) if match else 'utf-8' enc = match.group(1) if match else 'utf-8'
src = src.decode(enc) src = src.decode(enc)
# Python complains if there is a coding declaration in a unicode string # Python complains if there is a coding declaration in a unicode string
src = re.sub(r'^#.*coding\s*[:=]\s*([-\w.]+)', '#', src, flags=re.MULTILINE) src = re.sub(r'^#.*coding\s*[:=]\s*([-\w.]+)', '#', src.lstrip(u'\ufeff'), flags=re.MULTILINE)
# Translate newlines to \n # Translate newlines to \n
src = io.StringIO(src, newline=None).getvalue() src = io.StringIO(src, newline=None).getvalue()