This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: urllib2.Request.get_full_url() broken in newer versions of Python
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Stephen.White, jonsiddle, orsenthil, santoso.wijaya
Priority: normal Keywords:

Created on 2011-06-28 13:37 by jonsiddle, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (4)
msg139361 - (view) Author: Jon Siddle (jonsiddle) Date: 2011-06-28 13:37
Issue8280 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()
msg139370 - (view) Author: Santoso Wijaya (santoso.wijaya) * Date: 2011-06-28 17:27
This has been fixed with issue #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'
msg139423 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2011-06-29 14:51
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.
msg139837 - (view) Author: Stephen White (Stephen.White) Date: 2011-07-05 09:31
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.
History
Date User Action Args
2022-04-11 14:57:19adminsetgithub: 56640
2011-07-05 09:31:23Stephen.Whitesetnosy: + Stephen.White
messages: + msg139837
2011-06-29 14:51:38orsenthilsetstatus: open -> closed
resolution: not a bug
messages: + msg139423

stage: resolved
2011-06-28 17:27:43santoso.wijayasetnosy: + santoso.wijaya
messages: + msg139370
components: + Library (Lib)
2011-06-28 16:21:21ned.deilysetnosy: + orsenthil
2011-06-28 13:37:28jonsiddlecreate