mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-12 20:15:56 +00:00
open_url_in_browser: Surround subprocess creation with try-catch
Resolves #1363
This commit is contained in:
1 parent
d5724c4bd5
commit
885266ffb0
1 file changed
+12
-7
+12
-7
@@ -800,13 +800,18 @@ def open_url_in_browser(url: str, use_subprocess: bool = False) -> None:
|
||||
"""
|
||||
if use_subprocess:
|
||||
# Use a subprocess to avoid any output from webbrowser.open being written to stdout
|
||||
subprocess.Popen(
|
||||
[sys.executable, "-c", f"import webbrowser; webbrowser.open({url!r})"],
|
||||
stdin=subprocess.DEVNULL,
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL,
|
||||
start_new_session=False,
|
||||
)
|
||||
try:
|
||||
subprocess.Popen(
|
||||
[sys.executable, "-c", f"import webbrowser; webbrowser.open({url!r})"],
|
||||
stdin=subprocess.DEVNULL,
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL,
|
||||
start_new_session=False,
|
||||
)
|
||||
except Exception as e:
|
||||
# Subprocess creation can fail in rare cases (e.g. on some Linux systems; possibly subprocess/glibc bug)
|
||||
# See #1363
|
||||
log.error("Failed to open URL (%s) in subprocess; %s", url, e)
|
||||
else:
|
||||
import webbrowser
|
||||
|
||||
|
||||
Reference in new issue
Block a user