Skip to content

Commit 41452b3

Browse files
committed
Tiny simplification
1 parent ff5e729 commit 41452b3

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Lib/urllib/request.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,7 +1680,6 @@ def pathname2url(pathname):
16801680
pathname = pathname.replace('\\', '/')
16811681
encoding = sys.getfilesystemencoding()
16821682
errors = sys.getfilesystemencodeerrors()
1683-
prefix = ''
16841683
drive, root, tail = os.path.splitroot(pathname)
16851684
if drive:
16861685
# First, clean up some special forms. We are going to sacrifice the
@@ -1693,16 +1692,16 @@ def pathname2url(pathname):
16931692
# DOS drive specified. Add three slashes to the start, producing
16941693
# an authority section with a zero-length authority, and a path
16951694
# section starting with a single slash.
1696-
prefix = '///'
1695+
drive = '///' + drive
16971696
drive = quote(drive, encoding=encoding, errors=errors, safe='/:')
16981697
elif root:
16991698
# Add explicitly empty authority to absolute path. If the path
17001699
# starts with exactly one slash then this change is mostly
17011700
# cosmetic, but if it begins with two or more slashes then this
17021701
# avoids interpreting the path as a URL authority.
1703-
prefix = '//'
1702+
root = '//' + root
17041703
tail = quote(tail, encoding=encoding, errors=errors)
1705-
return prefix + drive + root + tail
1704+
return drive + root + tail
17061705

17071706

17081707
# Utility functions

0 commit comments

Comments
 (0)