From af3b9bf215d41216fd9f7578e678d3ddaefe344e Mon Sep 17 00:00:00 2001 From: c-holtermann Date: Mon, 15 Apr 2019 22:00:27 +0200 Subject: [PATCH 1/5] change shebang to python3 --- gnucash/python/pycons/console.py | 2 +- gnucash/python/pycons/ishell.py | 2 +- gnucash/python/pycons/shell.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gnucash/python/pycons/console.py b/gnucash/python/pycons/console.py index 760c498c28..ea418344fb 100644 --- a/gnucash/python/pycons/console.py +++ b/gnucash/python/pycons/console.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # # Copyright (c) 2008, Nicolas Rougier # All rights reserved. diff --git a/gnucash/python/pycons/ishell.py b/gnucash/python/pycons/ishell.py index 371f32c4a4..30e6ea4049 100644 --- a/gnucash/python/pycons/ishell.py +++ b/gnucash/python/pycons/ishell.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # # Adapted from: # diff --git a/gnucash/python/pycons/shell.py b/gnucash/python/pycons/shell.py index 33cff53592..6797b5b396 100644 --- a/gnucash/python/pycons/shell.py +++ b/gnucash/python/pycons/shell.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # # Copyright (c) 2008, Nicolas Rougier # All rights reserved. From d93d4efd82df063a3baa868774c1c6f35da10aed Mon Sep 17 00:00:00 2001 From: c-holtermann Date: Sat, 13 Apr 2019 18:13:19 +0200 Subject: [PATCH 2/5] Import necessary module gdk --- gnucash/python/pycons/console.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gnucash/python/pycons/console.py b/gnucash/python/pycons/console.py index ea418344fb..411dcdc05e 100644 --- a/gnucash/python/pycons/console.py +++ b/gnucash/python/pycons/console.py @@ -35,6 +35,7 @@ import gi gi.require_version('Gtk', '3.0') from gi.repository import GObject from gi.repository import Gtk +from gi.repository import Gdk from gi.repository import Pango import io import pycons.shell as shell From bf9ec70f27e3e86e5a901e2a86813369114c06de Mon Sep 17 00:00:00 2001 From: c-holtermann Date: Sat, 13 Apr 2019 18:16:32 +0200 Subject: [PATCH 3/5] reflect syntax change to sys tracebacks --- gnucash/python/pycons/shell.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gnucash/python/pycons/shell.py b/gnucash/python/pycons/shell.py index 6797b5b396..b5196b0155 100644 --- a/gnucash/python/pycons/shell.py +++ b/gnucash/python/pycons/shell.py @@ -163,10 +163,10 @@ class Shell: console.quit() else: try: - tb = sys.exc_traceback + tb = sys.exc_info()[2] if tb: tb=tb.tb_next - traceback.print_exception(sys.exc_type, sys.exc_value, tb) + traceback.print_exception(sys.exc_info()[0], sys.exc_info()[1], tb) except: sys.stderr, console.stderr = console.stderr, sys.stderr traceback.print_exc() From cc7673ccc89ebcdfa22dd223de1fd5a57c6f6764 Mon Sep 17 00:00:00 2001 From: c-holtermann Date: Sat, 13 Apr 2019 18:15:51 +0200 Subject: [PATCH 4/5] filter needs to be converted to list. Method replace is missing. Needs to be fixed. --- gnucash/python/pycons/shell.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gnucash/python/pycons/shell.py b/gnucash/python/pycons/shell.py index b5196b0155..d284e8b377 100644 --- a/gnucash/python/pycons/shell.py +++ b/gnucash/python/pycons/shell.py @@ -63,9 +63,9 @@ class Shell: """ s = line - s = filter(lambda x: x in '()[]{}"\'', s) - s = s.replace ("'''", "'") - s = s.replace ('"""', '"') + s = list(filter(lambda x: x in '()[]{}"\'', s)) + # s = s.replace ("'''", "'") + # s = s.replace ('"""', '"') instring = False brackets = {'(':')', '[':']', '{':'}', '"':'"', '\'':'\''} stack = [] From 5a73b9afd4010546c36c4761a098747bc7d8fd5c Mon Sep 17 00:00:00 2001 From: c-holtermann Date: Sat, 13 Apr 2019 18:16:12 +0200 Subject: [PATCH 5/5] syntax change to exec --- gnucash/python/pycons/shell.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnucash/python/pycons/shell.py b/gnucash/python/pycons/shell.py index d284e8b377..8458d343d7 100644 --- a/gnucash/python/pycons/shell.py +++ b/gnucash/python/pycons/shell.py @@ -155,7 +155,7 @@ class Shell: # Command output print(repr(r)) except SyntaxError: - exec(self.command in self.globals) + exec(str(self.command), self.globals) except: if hasattr (sys, 'last_type') and sys.last_type == SystemExit: console.quit()