Skip to content

Commit 8a3b5e1

Browse files
committed
Merge pull request python-mode#520 from chuan92/develop
Fix python-mode#482, (PEP 263 Python Source Code Encodings)
2 parents 9b2991c + e8c0ed0 commit 8a3b5e1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pymode/run.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
from .environment import env
77

88

9-
encoding = re(r'#[^\w]+coding:\s+utf.*$')
10-
9+
encoding = re(r'#.*coding[:=]\s*([-\w.]+)')
1110

1211
def run_code():
1312
""" Run python code in current buffer.
@@ -18,9 +17,12 @@ def run_code():
1817
errors, err = [], ''
1918
line1, line2 = env.var('a:line1'), env.var('a:line2')
2019
lines = __prepare_lines(line1, line2)
21-
for ix in (0, 1):
22-
if encoding.match(lines[ix]):
23-
lines.pop(ix)
20+
if encoding.match(lines[0]):
21+
lines.pop(0)
22+
if encoding.match(lines[0]):
23+
lines.pop(0)
24+
elif encoding.match(lines[1]):
25+
lines.pop(1)
2426

2527
context = dict(
2628
__name__='__main__',

0 commit comments

Comments
 (0)