-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Describe the bug
This might be considered an edge case but I've noticed that if the value tuple of a intersphinx_mapping
contains a base URI with a trailing slash and None
as the inventory file, Sphinx will try to load a URL with double slashes.
How to Reproduce
Using Sphinx 8.0.2 set the following in the conf.py
file of a sphinx-quickstart
project:
extensions = ["sphinx.ext.intersphinx"]
intersphinx_mapping = {'python': ('https://docs.python.org/3/', None)}
Run make html
and notice the double slashes in the output message:
...
loading intersphinx inventory 'python' from https://docs.python.org/3//objects.inv ...
...
The double slashes URL could be problematic depending on the web server setup.
Environment Information
Platform: linux; (Linux-6.5.0-45-generic-x86_64-with-glibc2.35)
Python version: 3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0])
Python implementation: CPython
Sphinx version: 8.0.2
Docutils version: 0.21.2
Jinja2 version: 3.1.4
Pygments version: 2.18.0
Sphinx extensions
["sphinx.ext.intersphinx"]
Additional context
I think the problem could have been introduced in #12087 where:
sphinx/sphinx/ext/intersphinx/_load.py
Lines 185 to 186 in f90b506
if not inv: | |
inv = posixpath.join(uri, INVENTORY_FILENAME) |
was changed into:
sphinx/sphinx/ext/intersphinx/_load.py
Line 214 in fadb6b1
inv = f'{project.target_uri}/{INVENTORY_FILENAME}' if location is None else location |
posixpath.join
removes the trailing slash in the target URI, but the f-string doesn't.