Skip to content
This repository was archived by the owner on Oct 21, 2022. It is now read-only.

Commit 23d78bc

Browse files
author
Sam Mason
committed
remove strange UTF stuff, code works for me without it on 2.7 and 3.4
1 parent 01e6cb1 commit 23d78bc

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

py-src/ltmain.py

+5-17
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,6 @@ def readlines(self):
4040
def read(self):
4141
return None
4242

43-
def asUnicode(s):
44-
try:
45-
return unicode(s)
46-
except:
47-
return str(s)
48-
49-
def ensureUtf(s):
50-
if type(s) == unicode:
51-
return s.encode('utf8', 'ignore')
52-
else:
53-
return str(s)
54-
5543
def findLoc(body, line, total):
5644
for i in range(len(body)):
5745
if body[i].lineno == line:
@@ -190,11 +178,11 @@ def handleEval(data):
190178
loc = form[0]
191179
isEval = False
192180
try:
193-
code= compile(ensureUtf(code), ensureUtf(data[2]["name"]), 'eval')
181+
code= compile(code, str(data[2]["name"]), 'eval')
194182
isEval = True
195183
except:
196184
try:
197-
code= compile(ensureUtf(code), ensureUtf(data[2]["name"]), 'exec')
185+
code= compile(code, str(data[2]["name"]), 'exec')
198186
except:
199187
e = traceback.format_exc()
200188
send(data[0], "editor.eval.python.exception", {"ex": cleanTrace(e), "meta": loc})
@@ -203,7 +191,7 @@ def handleEval(data):
203191
try:
204192
if isEval:
205193
result = eval(code, module.__dict__)
206-
send(data[0], "editor.eval.python.result", {"meta": loc, "result": asUnicode(result)})
194+
send(data[0], "editor.eval.python.result", {"meta": loc, "result": str(result)})
207195
else:
208196
exec(code, module.__dict__)
209197
send(data[0], "editor.eval.python.success", {"meta": loc})
@@ -260,11 +248,11 @@ def ipyEval(data):
260248
loc = form[0]
261249
isEval = False
262250
try:
263-
compile(ensureUtf(code), ensureUtf(data[2]["name"]), 'eval')
251+
compile(code, str(data[2]["name"]), 'eval')
264252
isEval = True
265253
except:
266254
try:
267-
compile(ensureUtf(code), ensureUtf(data[2]["name"]), 'exec')
255+
compile(code, str(data[2]["name"]), 'exec')
268256
except:
269257
e = traceback.format_exc()
270258
send(data[0], "editor.eval.python.exception", {"ex": cleanTrace(e), "meta": loc})

0 commit comments

Comments
 (0)