| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 60c4c08 commit 6d8952c
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -96,23 +96,19 @@ def __init__(self, locals=None, encoding=None): | |||
| 96 | 96 | def reset_running_time(self): | |
| 97 | 97 | self.running_time = 0 | |
| 98 | 98 | ||
| 99 | - if py3: | ||
| 100 | - | ||
| 101 | - def runsource(self, source, filename="<input>", symbol="single"): | ||
| 102 | - with self.timer: | ||
| 103 | - return code.InteractiveInterpreter.runsource(self, source, | ||
| 104 | - filename, symbol) | ||
| 105 | - | ||
| 106 | - else: | ||
| 107 | - | ||
| 108 | - def runsource(self, source, filename='<input>', symbol='single', | ||
| 109 | - encode=True): | ||
| 110 | - with self.timer: | ||
| 111 | - if encode: | ||
| 112 | - source = u'# coding: %s\n%s' % (self.encoding, source) | ||
| 113 | - source = source.encode(self.encoding) | ||
| 114 | - return code.InteractiveInterpreter.runsource(self, source, | ||
| 115 | - filename, symbol) | ||
| 99 | + def runsource(self, source, filename='<input>', symbol='single', | ||
| 100 | + encode=True): | ||
| 101 | + """Execute Python code. | ||
| 102 | + | ||
| 103 | + source, filename and symbol are passed on to | ||
| 104 | + code.InteractiveInterpreter.runsource. If encode is True, the source | ||
| 105 | + will be encoded. On Python 3.X, encode will be ignored.""" | ||
| 106 | + if not py3 and encode: | ||
| 107 | + source = u'# coding: %s\n%s' % (self.encoding, source) | ||
| 108 | + source = source.encode(self.encoding) | ||
| 109 | + with self.timer: | ||
| 110 | + return code.InteractiveInterpreter.runsource(self, source, | ||
| 111 | + filename, symbol) | ||
| 116 | 112 | ||
| 117 | 113 | def showsyntaxerror(self, filename=None): | |
| 118 | 114 | """Override the regular handler, the code's copied and pasted from | |
@@ -409,7 +405,11 @@ def startup(self): | |||
| 409 | 405 | if filename: | |
| 410 | 406 | encoding = inspection.get_encoding_file(filename) | |
| 411 | 407 | with io.open(filename, 'rt', encoding=encoding) as f: | |
| 412 | - self.interp.runsource(f.read(), filename, 'exec') | ||
| 408 | + source = f.read() | ||
| 409 | + if not py3: | ||
| 410 | + # Python 2.6 and early 2.7.X need bytes. | ||
| 411 | + source = source.encode(encoding) | ||
| 412 | + self.interp.runsource(source, filename, 'exec', encode=False) | ||
| 413 | 413 | ||
| 414 | 414 | def current_string(self, concatenate=False): | |
| 415 | 415 | """If the line ends in a string get it, otherwise return ''""" | |
| Back | FazBrowse Home | New Git URL |
0 commit comments