Skip to content

Commit 1e2d9a2

Browse files
committed
Make encoding regexp less strict
Make the encoding detection regexp less strict so that it will detect the encoding of files that do not have a space between the "coding:" statement and the encoding value. Example: https://github.com/dateutil/dateutil/blob/master/dateutil/parser.py
1 parent fd70ac2 commit 1e2d9a2

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

pymode/libs3/rope/base/fscommands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def read_str_coding(source):
242242
if not isinstance(source, str):
243243
source = source.decode("utf-8", "ignore")
244244
#TODO: change it to precompiled version
245-
mex = re.search("\-\*\-\s+coding:\s+(.*?)\s+\-\*\-", source)
245+
mex = re.search("\-\*\-\s+coding:\s*(.*?)\s+\-\*\-", source)
246246
if mex:
247247
return mex.group(1)
248248
return "utf-8"

0 commit comments

Comments
 (0)