mirror of
https://github.com/LorenEteval/Furious.git
synced 2026-09-30 19:08:03 +03:00
Add stdout/stderr redirect guard for pythonw.exe
Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
+22
-1
@@ -129,12 +129,33 @@ class Core:
|
||||
class StdoutRedirectHelper:
|
||||
TemporaryDir = QtCore.QTemporaryDir()
|
||||
|
||||
@staticmethod
|
||||
def isRealFile(file):
|
||||
if not hasattr(file, 'fileno'):
|
||||
return False
|
||||
|
||||
try:
|
||||
tmp = os.dup(file.fileno())
|
||||
except Exception:
|
||||
# Any non-exit exceptions
|
||||
|
||||
return False
|
||||
else:
|
||||
os.close(tmp)
|
||||
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def launch(msgQueue, entrypoint):
|
||||
if not callable(entrypoint):
|
||||
return
|
||||
|
||||
if not StdoutRedirectHelper.TemporaryDir.isValid():
|
||||
if (
|
||||
not StdoutRedirectHelper.TemporaryDir.isValid()
|
||||
# pythonw.exe
|
||||
or not StdoutRedirectHelper.isRealFile(sys.__stdout__)
|
||||
or not StdoutRedirectHelper.isRealFile(sys.__stderr__)
|
||||
):
|
||||
# Call entrypoint directly
|
||||
entrypoint()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user