File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,9 +27,12 @@ def url2pathname(url):
2727 drive = comp [0 ][- 1 ].upper ()
2828 components = comp [1 ].split ('/' )
2929 path = drive + ':'
30- for comp in components :
30+ for comp in components :
3131 if comp :
3232 path = path + '\\ ' + urllib .parse .unquote (comp )
33+ # Issue #11474 - handing url such as |c/|
34+ if path .endswith (':' ) and url .endswith ('/' ):
35+ path += '\\ '
3336 return path
3437
3538def pathname2url (p ):
Original file line number Diff line number Diff line change 99import unittest
1010from test import support
1111import os
12+ import sys
1213import tempfile
1314
1415def hexescape (char ):
@@ -1021,6 +1022,23 @@ def test_quoting(self):
10211022 "url2pathname() failed; %s != %s" %
10221023 (expect , result ))
10231024
1025+ @unittest .skipUnless (sys .platform == 'win32' ,
1026+ 'test specific to the urllib.url2path function.' )
1027+ def test_ntpath (self ):
1028+ given = ('/C:/' , '///C:/' , '/C|//' )
1029+ expect = 'C:\\ '
1030+ for url in given :
1031+ result = urllib .request .url2pathname (url )
1032+ self .assertEqual (expect , result ,
1033+ 'urllib.request..url2pathname() failed; %s != %s' %
1034+ (expect , result ))
1035+ given = '///C|/path'
1036+ expect = 'C:\\ path'
1037+ result = urllib .request .url2pathname (given )
1038+ self .assertEqual (expect , result ,
1039+ 'urllib.request.url2pathname() failed; %s != %s' %
1040+ (expect , result ))
1041+
10241042class Utility_Tests (unittest .TestCase ):
10251043 """Testcase to test the various utility functions in the urllib."""
10261044
Original file line number Diff line number Diff line change @@ -53,6 +53,9 @@ Core and Builtins
5353Library
5454-------
5555
56+ - Issue #11474: Fix the bug with url2pathname() handling of '/C|/' on Windows.
57+ Patch by Santoso Wijaya.
58+
5659- Issue #9233: Fix json.loads('{}') to return a dict (instead of a list), when
5760 _json is not available.
5861
You can’t perform that action at this time.
0 commit comments