Skip to content

Commit 9f1a339

Browse files
add a blank line after Python 2 source encoding
fixes bpython#578
1 parent 4cd5453 commit 9f1a339

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

bpython/repl.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def runsource(self, source, filename=None, symbol='single',
104104
code.InteractiveInterpreter.runsource. If encode is True, the source
105105
will be encoded. On Python 3.X, encode will be ignored."""
106106
if not py3 and encode:
107-
source = u'# coding: %s\n%s' % (self.encoding, source)
107+
source = u'# coding: %s\n\n%s' % (self.encoding, source)
108108
source = source.encode(self.encoding)
109109
if filename is None:
110110
filename = filename_for_console_input(source)
@@ -132,7 +132,7 @@ def showsyntaxerror(self, filename=None):
132132
else:
133133
# Stuff in the right filename and right lineno
134134
if not py3:
135-
lineno -= 1
135+
lineno -= 2
136136
value = SyntaxError(msg, (filename, lineno, offset, line))
137137
sys.last_value = value
138138
list = traceback.format_exception_only(type, value)
@@ -153,7 +153,7 @@ def showtraceback(self):
153153
if not py3:
154154
for i, (fname, lineno, module, something) in enumerate(tblist):
155155
if fname == '<input>':
156-
tblist[i] = (fname, lineno - 1, module, something)
156+
tblist[i] = (fname, lineno - 2, module, something)
157157

158158
l = traceback.format_list(tblist)
159159
if l:

0 commit comments

Comments
 (0)