Skip to content

Fix --outdir to pass a str to webbrowser.open_new_tab()#2

Merged
hugovk merged 2 commits intomainfrom
fix-outdir
Mar 23, 2026
Merged

Fix --outdir to pass a str to webbrowser.open_new_tab()#2
hugovk merged 2 commits intomainfrom
fix-outdir

Conversation

@hugovk
Copy link
Copy Markdown
Owner

@hugovk hugovk commented Mar 23, 2026

Same as nschloe#171.


❯ python --version
Python 3.12.4
❯ python -X importtime -c 'import pprint' 2> import.log && tuna import.log -o /tmp/tuna-html
Exception in thread Thread-1 (<lambda>):
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/threading.py", line 1010, in run
    self._target(*self._args, **self._kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/tuna/cli.py", line 29, in <lambda>
    target=lambda: webbrowser.open_new_tab(outdir / "index.html")
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/webbrowser.py", line 103, in open_new_tab
    return open(url, 2)
           ^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/webbrowser.py", line 87, in open
    if browser.open(url, new, autoraise):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/webbrowser.py", line 639, in open
    script = 'open location "%s"' % url.replace('"', '%22') # opens in default browser
                                    ^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Path.replace() takes 2 positional arguments but 3 were given

This is because webbrowser.open_new_tab(url) expects url to be a str, not a pathlib.Path.

Also remove some redundant parentheses.

@hugovk hugovk force-pushed the fix-outdir branch 2 times, most recently from 4f232eb to 7514dba Compare March 23, 2026 10:57
@hugovk hugovk merged commit 4a404aa into main Mar 23, 2026
7 of 8 checks passed
@hugovk hugovk deleted the fix-outdir branch April 11, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant