Skip to content

Commit

Permalink
Ports: Register Browser in the Python webbrowser module
Browse files Browse the repository at this point in the history
This makes the following work:

    >>> import webbrowser
    >>> webbrowser.open("http:https://serenityos.org")

As well as this well-known easter egg:

    >>> import antigravity

Pretty cool! :^)
  • Loading branch information
linusg committed May 6, 2021
1 parent 8779964 commit 9f970c3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Ports/python3/patches/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
12 changes: 12 additions & 0 deletions Ports/python3/patches/webbrowser.patch
Original file line number Diff line number Diff line change
@@ -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:

0 comments on commit 9f970c3

Please sign in to comment.