New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
urllib2.Request.get_full_url() broken in newer versions of Python #56640
Comments
bpo-8280 fixed an issue where the fragment was being sent to the server (and returned by get_selector). Unfortunately the fix means that the "full" URL stored in the Request no longer includes the fragment either. This is in contradiction to the documentation which states: Request.get_full_url()
Return the URL given in the constructor. Yet: >>> import urllib2
>>> urllib2.Request("http://host/path#fragment").get_full_url()
'http://host/path' The particular use case is a custom scheme handler, which should be able to use the whole of the opaque part of the URL to operate. Ie, our code wants to do something like this: urllib2.Request("foo://opaquestring#opaquestring").get_full_url() |
This has been fixed with issue bpo-11703, latest version of Python 2.7 does not exhibit this behaviour anymore: Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib2
>>> urllib2.Request('http://host/path#fragment').get_full_url()
'http://host/path#fragment' |
As Santosa said, this was discovered and fixed in 2.7 itself, surprised that you discovered it in any release Jon. If it was from a checkout, please update. |
Just to confirm that it was a release, but 2.7.1 so not the current. Doesn't appear to happen in Python 2.7 (as shipped with Fedora Core 14) or in Python 2.7.2. C:\>\Python27\python.exe
Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib2
>>> urllib2.Request("http://host/path#fragment").get_full_url()
'http://host/path'
>>> Upgrading our affected Windows boxes to Python 2.7.2 seems to solve the problem. We're happy for this bug to remain closed. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: