From 9f970c3459be761c6d1ac192eb494d630b4ca1ed Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Thu, 6 May 2021 14:26:09 +0100 Subject: [PATCH] Ports: Register Browser in the Python webbrowser module This makes the following work: >>> import webbrowser >>> webbrowser.open("http://serenityos.org") As well as this well-known easter egg: >>> import antigravity Pretty cool! :^) --- Ports/python3/patches/ReadMe.md | 4 ++++ Ports/python3/patches/webbrowser.patch | 12 ++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 Ports/python3/patches/webbrowser.patch diff --git a/Ports/python3/patches/ReadMe.md b/Ports/python3/patches/ReadMe.md index cf3fd48e45..b799f05a34 100644 --- a/Ports/python3/patches/ReadMe.md +++ b/Ports/python3/patches/ReadMe.md @@ -23,3 +23,7 @@ Our stub implementation of `setlocale()` always returns `nullptr`, which the int ## `tweak-unsupported-printf-format-specifiers.patch` Replace uses of `%.Ns` with `%s` as the former is not supported by our `printf` implementation yet and would result in empty strings. It uses `snprintf` already, so this is safe. + +## `webbrowser.patch` + +Register the SerenityOS Browser in the [`webbrowser`](https://docs.python.org/3/library/webbrowser.html) module. diff --git a/Ports/python3/patches/webbrowser.patch b/Ports/python3/patches/webbrowser.patch new file mode 100644 index 0000000000..9e1584d5dc --- /dev/null +++ b/Ports/python3/patches/webbrowser.patch @@ -0,0 +1,12 @@ +--- Python-3.9.5/Lib/webbrowser.py 2021-05-03 15:54:42.000000000 +0100 ++++ Python-3.9.5/Lib/webbrowser.py 2021-05-06 14:21:34.242964786 +0100 +@@ -574,6 +574,9 @@ + if shutil.which("w3m"): + register("w3m", None, GenericBrowser("w3m")) + ++ # SerenityOS Browser ++ register("Browser", None, BackgroundBrowser("Browser")) ++ + # OK, now that we know what the default preference orders for each + # platform are, allow user to override them with the BROWSER variable. + if "BROWSER" in os.environ: