From 01e6cb1d06adfec0b098e83c95e89a8d700f7185 Mon Sep 17 00:00:00 2001 From: Sam Mason Date: Tue, 11 Aug 2015 12:08:46 +0100 Subject: [PATCH 1/3] added .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..076a0df --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__pycache/ +*.pyc From 23d78bc483bece66923576006765f7578549f99c Mon Sep 17 00:00:00 2001 From: Sam Mason Date: Tue, 11 Aug 2015 12:11:04 +0100 Subject: [PATCH 2/3] remove strange UTF stuff, code works for me without it on 2.7 and 3.4 --- py-src/ltmain.py | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/py-src/ltmain.py b/py-src/ltmain.py index e07f173..044aafb 100644 --- a/py-src/ltmain.py +++ b/py-src/ltmain.py @@ -40,18 +40,6 @@ def readlines(self): def read(self): return None -def asUnicode(s): - try: - return unicode(s) - except: - return str(s) - -def ensureUtf(s): - if type(s) == unicode: - return s.encode('utf8', 'ignore') - else: - return str(s) - def findLoc(body, line, total): for i in range(len(body)): if body[i].lineno == line: @@ -190,11 +178,11 @@ def handleEval(data): loc = form[0] isEval = False try: - code= compile(ensureUtf(code), ensureUtf(data[2]["name"]), 'eval') + code= compile(code, str(data[2]["name"]), 'eval') isEval = True except: try: - code= compile(ensureUtf(code), ensureUtf(data[2]["name"]), 'exec') + code= compile(code, str(data[2]["name"]), 'exec') except: e = traceback.format_exc() send(data[0], "editor.eval.python.exception", {"ex": cleanTrace(e), "meta": loc}) @@ -203,7 +191,7 @@ def handleEval(data): try: if isEval: result = eval(code, module.__dict__) - send(data[0], "editor.eval.python.result", {"meta": loc, "result": asUnicode(result)}) + send(data[0], "editor.eval.python.result", {"meta": loc, "result": str(result)}) else: exec(code, module.__dict__) send(data[0], "editor.eval.python.success", {"meta": loc}) @@ -260,11 +248,11 @@ def ipyEval(data): loc = form[0] isEval = False try: - compile(ensureUtf(code), ensureUtf(data[2]["name"]), 'eval') + compile(code, str(data[2]["name"]), 'eval') isEval = True except: try: - compile(ensureUtf(code), ensureUtf(data[2]["name"]), 'exec') + compile(code, str(data[2]["name"]), 'exec') except: e = traceback.format_exc() send(data[0], "editor.eval.python.exception", {"ex": cleanTrace(e), "meta": loc}) From 7914a35fee9fe139316747925f21552f80e7f8a0 Mon Sep 17 00:00:00 2001 From: Sam Mason Date: Tue, 11 Aug 2015 12:11:55 +0100 Subject: [PATCH 3/3] compatibility with IPython 3.2 --- py-src/ltipy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py-src/ltipy.py b/py-src/ltipy.py index f3229c5..0073964 100644 --- a/py-src/ltipy.py +++ b/py-src/ltipy.py @@ -51,7 +51,7 @@ def km_from_string(s=''): km = KernelManager(connection_file = fullpath) km.load_connection_file() km.start_channels() - send = km.shell_channel.execute + send = km.shell_channel.execute # not sure if this should be changed as well respond(None, "python.client.error.ipython-version", None) return @@ -71,7 +71,7 @@ def km_from_string(s=''): km.load_connection_file() kc = km.client() kc.start_channels() - send = kc.shell_channel.execute + send = kc.execute return km def _extract_traceback(traceback):