From 23197d5e00a8f7e7070ea3b35117c1e35eb1208b Mon Sep 17 00:00:00 2001 From: Ted Date: Thu, 10 Apr 2014 12:32:46 -0400 Subject: [PATCH 1/2] Updates to work with python3 -- with these changes it worksforme(tm) --- pyzen/core.py | 4 ++-- pyzen/simple.py | 4 ++-- pyzen/ui/win32/__init__.py | 2 +- pyzen/ui/win32/wrappers.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pyzen/core.py b/pyzen/core.py index eca3247..7c025d7 100644 --- a/pyzen/core.py +++ b/pyzen/core.py @@ -5,7 +5,7 @@ import traceback from multiprocessing import Process, Queue from threading import Thread, Lock -from Queue import Empty +from queue import Empty from pyzen.ui import load_ui @@ -52,7 +52,7 @@ def run(self): mtimes[filename] = mtime continue if mtime > mtimes[filename]: - print >> sys.stderr, 'Detected modification of %s, restarting.' % filename + print('Detected modification of %s, restarting.' % filename, file=sys.stderr) self.do_reload = True sys.exit(MAGIC_RETURN_CODE) time.sleep(_SLEEP_TIME) diff --git a/pyzen/simple.py b/pyzen/simple.py index 58fac50..afa4e0c 100644 --- a/pyzen/simple.py +++ b/pyzen/simple.py @@ -28,8 +28,8 @@ def run_tests(argv): # Run the code fail = False try: - exec compiled in mod.__dict__ - except SystemExit, e: + exec(compiled, mod.__dict__) + except SystemExit as e: if e.code: fail = True diff --git a/pyzen/ui/win32/__init__.py b/pyzen/ui/win32/__init__.py index 350c24e..346de5c 100644 --- a/pyzen/ui/win32/__init__.py +++ b/pyzen/ui/win32/__init__.py @@ -26,7 +26,7 @@ def main(): time.sleep(2) t.post_message(WM_APP, 1, 2) time.sleep(1) - print 'Sending quit' + print('Sending quit') t.quit() if __name__ == '__main__': diff --git a/pyzen/ui/win32/wrappers.py b/pyzen/ui/win32/wrappers.py index c1cb725..83264cf 100644 --- a/pyzen/ui/win32/wrappers.py +++ b/pyzen/ui/win32/wrappers.py @@ -67,7 +67,7 @@ def message_loop(hwnd, wndproc): else: DispatchMessage(byref(msg)) except WindowsError: - print 'Error processing msg(%s, %s, %s)'%(msg.message, msg.wParam, msg.lParam) + print('Error processing msg(%s, %s, %s)'%(msg.message, msg.wParam, msg.lParam)) continue class NotifyData(Structure): From 7e6084845b38126667c0011fc6fefe22ef2967b4 Mon Sep 17 00:00:00 2001 From: Ted Date: Thu, 10 Apr 2014 13:37:49 -0400 Subject: [PATCH 2/2] Adds "from future import" for backward compatibility. --- pyzen/core.py | 9 ++++++++- pyzen/simple.py | 1 + pyzen/ui/win32/__init__.py | 1 + pyzen/ui/win32/wrappers.py | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pyzen/core.py b/pyzen/core.py index 7c025d7..1d67565 100644 --- a/pyzen/core.py +++ b/pyzen/core.py @@ -1,11 +1,18 @@ from __future__ import with_statement +from __future__ import print_function import sys import os import time import traceback from multiprocessing import Process, Queue from threading import Thread, Lock -from queue import Empty +try: + #Python3 + from queue import Empty +except ImportError: + #Python2 + from Queue import Empty + from pyzen.ui import load_ui diff --git a/pyzen/simple.py b/pyzen/simple.py index afa4e0c..bc64817 100644 --- a/pyzen/simple.py +++ b/pyzen/simple.py @@ -1,3 +1,4 @@ +from __future__ import print_function import sys import os import copy diff --git a/pyzen/ui/win32/__init__.py b/pyzen/ui/win32/__init__.py index 346de5c..b974868 100644 --- a/pyzen/ui/win32/__init__.py +++ b/pyzen/ui/win32/__init__.py @@ -1,3 +1,4 @@ +from __future__ import print_function from pyzen.ui.base import PyZenUI class Win32UI(PyZenUI): diff --git a/pyzen/ui/win32/wrappers.py b/pyzen/ui/win32/wrappers.py index 83264cf..9482857 100644 --- a/pyzen/ui/win32/wrappers.py +++ b/pyzen/ui/win32/wrappers.py @@ -1,3 +1,4 @@ +from __future__ import print_function import threading from pyzen.ui.win32.types import *