Skip to content

Commit

Permalink
Fix python-mode#482, (PEP 263 Python Source Code Encodings)
Browse files Browse the repository at this point in the history
  • Loading branch information
chuan92 committed Jan 12, 2015
1 parent 95c4190 commit e8c0ed0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pymode/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
from .environment import env


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

encoding = re(r'#.*coding[:=]\s*([-\w.]+)')

def run_code():
""" Run python code in current buffer.
Expand All @@ -18,9 +17,12 @@ def run_code():
errors, err = [], ''
line1, line2 = env.var('a:line1'), env.var('a:line2')
lines = __prepare_lines(line1, line2)
for ix in (0, 1):
if encoding.match(lines[ix]):
lines.pop(ix)
if encoding.match(lines[0]):
lines.pop(0)
if encoding.match(lines[0]):
lines.pop(0)
elif encoding.match(lines[1]):
lines.pop(1)

context = dict(
__name__='__main__',
Expand Down

0 comments on commit e8c0ed0

Please sign in to comment.