Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a99b7619
Commit
a99b7619
authored
Apr 14, 2011
by
Senthil Kumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Issue11474 - url2pathname() handling of '/C|/' on Windows
parent
7f9d2ead
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
2 deletions
+26
-2
Lib/nturl2path.py
Lib/nturl2path.py
+5
-2
Lib/test/test_urllib.py
Lib/test/test_urllib.py
+18
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/nturl2path.py
View file @
a99b7619
...
...
@@ -25,11 +25,14 @@ def url2pathname(url):
error
=
'Bad URL: '
+
url
raise
IOError
,
error
drive
=
comp
[
0
][
-
1
].
upper
()
components
=
comp
[
1
].
split
(
'/'
)
path
=
drive
+
':'
for
comp
in
components
:
components
=
comp
[
1
].
split
(
'/'
)
for
comp
in
components
:
if
comp
:
path
=
path
+
'
\
\
'
+
urllib
.
unquote
(
comp
)
# Issue #11474: url like '/C|/' should convert into 'C:\\'
if
path
.
endswith
(
':'
)
and
url
.
endswith
(
'/'
):
path
+=
'
\
\
'
return
path
def
pathname2url
(
p
):
...
...
Lib/test/test_urllib.py
View file @
a99b7619
...
...
@@ -5,6 +5,7 @@ import httplib
import
unittest
from
test
import
test_support
import
os
import
sys
import
mimetools
import
tempfile
import
StringIO
...
...
@@ -630,6 +631,23 @@ class Pathname_Tests(unittest.TestCase):
"url2pathname() failed; %s != %s" %
(expect, result))
@unittest.skipUnless(sys.platform == '
win32
',
'
test
specific
to
the
nturl2path
library
')
def test_ntpath(self):
given = ('
/
C
:
/
', '
///
C
:
/
', '
/
C
|//
')
expect = '
C
:
\\
'
for url in given:
result = urllib.url2pathname(url)
self.assertEqual(expect, result,
'
nturl2path
.
url2pathname
()
failed
;
%
s
!=
%
s
' %
(expect, result))
given = '
///
C
|/
path
'
expect = '
C
:
\\
path
'
result = urllib.url2pathname(given)
self.assertEqual(expect, result,
'
nturl2path
.
url2pathname
()
failed
;
%
s
!=
%
s
' %
(expect, result))
class Utility_Tests(unittest.TestCase):
"""Testcase to test the various utility functions in the urllib."""
...
...
Misc/NEWS
View file @
a99b7619
...
...
@@ -51,6 +51,9 @@ Core and Builtins
Library
-------
- Issue #11474: Fix the bug with url2pathname() handling of '
/
C
|/
' on Windows.
Patch by Santoso Wijaya.
- Issue #9233: Fix json.loads('
{}
') to return a dict (instead of a list), when
_json is not available.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment