Skip to content

Commit 5050d30

Browse files
committed
Fix globals handling in debugger
1 parent 1b41b82 commit 5050d30

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

studio/debugtools/debugger.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# Copyright (C) 2022 Hoverset Group. #
33
# ======================================================================= #
44

5+
_global_freeze = dict(globals())
6+
57
import sys
68
import tkinter
79
import logging
@@ -197,7 +199,10 @@ def run(cls, path=None):
197199
cls._hook()
198200
with open(path) as file:
199201
code = compile(file.read(), path, 'exec')
200-
exec(code, {'__name__': '__main__'})
202+
203+
# Ensure hooked application thinks it is running as __main__
204+
_global_freeze.update({"__name__": "__main__", "__file__": path})
205+
exec(code, _global_freeze)
201206

202207
@classmethod
203208
def run_process(cls, path) -> subprocess.Popen:

0 commit comments

Comments
 (0)