Skip to content

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

Closed
hugovk wants to merge 2 commits intonschloe:mainfrom
hugovk:fix-outdir
Closed

Fix --outdir to pass a str to webbrowser.open_new_tab()#171
hugovk wants to merge 2 commits intonschloe:mainfrom
hugovk:fix-outdir

Conversation

@hugovk
Copy link
Copy Markdown
Contributor

@hugovk hugovk commented Aug 6, 2024

❯ 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.

@nschloe
Copy link
Copy Markdown
Owner

nschloe commented Apr 11, 2026

Can't resolve the diff (changes in main are large), but I'll make sure this works.

@nschloe nschloe closed this Apr 11, 2026
@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.

2 participants