Skip to content

Commit

Permalink
fix script entry guard - ignore errors if stdio does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
robhagemans committed Aug 3, 2022
1 parent 53132d6 commit 08b78d7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pcbasic/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# not available in Python <= 3.6

try:
import importlib_resources as resources
import importlib_resources as resources
except ImportError: # pragma: no cover
from importlib import resources

Expand Down Expand Up @@ -121,6 +121,12 @@ def script_entry_point_guard():
except Exception:
exit_code = True
if exit_code:
os.dup2(os.open(os.devnull, os.O_WRONLY), sys.stdout.fileno())
os.dup2(os.open(os.devnull, os.O_WRONLY), sys.stderr.fileno())
try:
os.dup2(os.open(os.devnull, os.O_WRONLY), sys.stdout.fileno())
except Exception:
pass
try:
os.dup2(os.open(os.devnull, os.O_WRONLY), sys.stderr.fileno())
except Exception:
pass
sys.exit(exit_code)

0 comments on commit 08b78d7

Please sign in to comment.