fish_config: Fix on python < 3.12 if not on Windows

This commit is contained in:
Fabian Boehm 2024-01-12 18:42:55 +01:00
parent 8009469f8f
commit 23a8967ecb

View File

@ -1674,13 +1674,20 @@ url = "http://localhost:%d/%s/%s" % (PORT, authkey, initial_tab)
# Create temporary file to hold redirect to real server. This prevents exposing # Create temporary file to hold redirect to real server. This prevents exposing
# the URL containing the authentication key on the command line (see # the URL containing the authentication key on the command line (see
# CVE-2014-2914 or https://github.com/fish-shell/fish-shell/issues/1438). # CVE-2014-2914 or https://github.com/fish-shell/fish-shell/issues/1438).
#
# If on Windows, the file needs to be closed after writing, otherwise, the browser won't be able to open it."
# unfortunately this was added in python 3.12, so we don't add it on other platforms
# to support older python versions there.
kwargs = {}
if is_windows():
kwargs["delete_on_close"] = False
f = tempfile.NamedTemporaryFile( f = tempfile.NamedTemporaryFile(
prefix="web_config", prefix="web_config",
suffix=".html", suffix=".html",
mode="w", mode="w",
delete=True, delete=True,
# If on Windows, the file needs to be closed after writing, otherwise, the browser won't be able to open it." **kwargs,
delete_on_close=not is_windows(),
) )
f.write(redirect_template_html % (url, url)) f.write(redirect_template_html % (url, url))