diff --git a/pyzen/core.py b/pyzen/core.py index eca3247..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 @@ -52,7 +59,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..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 @@ -28,8 +29,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..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): @@ -26,7 +27,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..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 * @@ -67,7 +68,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):