summaryrefslogtreecommitdiffstats
path: root/Lib/urllib/request.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/urllib/request.py')
-rw-r--r--Lib/urllib/request.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
index 9e55543..1fcaa89 100644
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -1667,9 +1667,11 @@ else:
def pathname2url(pathname):
"""OS-specific conversion from a file system path to a relative URL
of the 'file' scheme; not recommended for general use."""
- if pathname[:2] == '//':
- # Add explicitly empty authority to avoid interpreting the path
- # as authority.
+ if pathname[:1] == '/':
+ # Add explicitly empty authority to absolute path. If the path
+ # starts with exactly one slash then this change is mostly
+ # cosmetic, but if it begins with two or more slashes then this
+ # avoids interpreting the path as a URL authority.
pathname = '//' + pathname
encoding = sys.getfilesystemencoding()
errors = sys.getfilesystemencodeerrors()