Commit 9d37edfb authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Some python3 adaptions

parent 7ea14447
...@@ -163,11 +163,14 @@ class Importer: ...@@ -163,11 +163,14 @@ class Importer:
BAD = None BAD = None
try: try:
code = compile(src, "%s/%s" % (self.path, filename), 'exec') code = compile(src, "%s/%s" % (self.path, filename), 'exec')
exec code in mod.__dict__ if sys.version_info < (3,):
except exceptions.SystemExit, e: exec("exec code in mod.__dict__")
else:
exec(code, mod.__dict__)
except SystemExit as e:
# Silently propagate exit # Silently propagate exit
raise e raise e
except Exception, e: except Exception as e:
# Silently propagate other exceptions as well # Silently propagate other exceptions as well
BAD = sys.exc_info() BAD = sys.exc_info()
raise e raise e
...@@ -204,18 +207,17 @@ def extract(dest='.'): ...@@ -204,18 +207,17 @@ def extract(dest='.'):
f = file(filepath, 'w') f = file(filepath, 'w')
f.write(c) f.write(c)
f.close() f.close()
os.chmod(filepath, 0755) os.chmod(filepath, 0o755)
if __name__ == '__main__': if __name__ == '__main__':
import sys import sys
importer = Importer(code) importer = Importer(code)
sys.path_hooks.append(importer) sys.path_hooks.append(importer)
import exceptions
import imp import imp
try: try:
# This will start actual execution # This will start actual execution
importer.load_module("__main__") importer.load_module("__main__")
except exceptions.SystemExit, e: except SystemExit as e:
raise e raise e
except: except:
if BAD: if BAD:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment