Reputation: 27969
I have two systems:
First one work as intended:
>>> urlparse.urlparse('foo://bar/?blu=1')
ParseResult(scheme='foo', netloc='bar', path='/', params='', query='blu=1', fragment='')
# sys.version_info(major=2, minor=7, micro=12, releaselevel='final', serial=0)
The second one does it different:
>>> urlparse.urlparse('foo://bar/?blu=1')
ParseResult(scheme='foo', netloc='bar', path='/?blu=1', params='', query='', fragment='')
#sys.version_info(major=2, minor=7, micro=3, releaselevel='final', serial=0)
What's wrong here?
Both use Python 2.7.
Upvotes: 3
Views: 185
Reputation: 1123400
The second machine is running a very ancient Python 2.7 release. You have run into issue 9374, a fix for which landed in Python 2.7.4rc1, which released on 2013-03-23, so it's a 2.7 release older than that.
From the 2.7.4rc1 NEWS file:
- Issue #9374: Generic parsing of query and fragment portions of url for any scheme. Supported both by RFC3986 and RFC2396.
The patch that fixes it is not that big, you could just copy the fixed urlsplit()
function and monkey patch urllib
with that if you can't upgrade that machine (you'll have to import some _private
names from urllib
first, of course).
Upvotes: 9