Skip to content
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

Closed
jonsiddle mannequin opened this issue Jun 28, 2011 · 4 comments
Closed

urllib2.Request.get_full_url() broken in newer versions of Python #56640

jonsiddle mannequin opened this issue Jun 28, 2011 · 4 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@jonsiddle
Copy link
Mannequin

jonsiddle mannequin commented Jun 28, 2011

BPO 12431
Nosy @orsenthil

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:

assignee = None
closed_at = <Date 2011-06-29.14:51:38.004>
created_at = <Date 2011-06-28.13:37:28.137>
labels = ['invalid', 'type-bug', 'library']
title = 'urllib2.Request.get_full_url() broken in newer versions of Python'
updated_at = <Date 2011-07-05.09:31:23.467>
user = 'https://bugs.python.org/jonsiddle'

bugs.python.org fields:

activity = <Date 2011-07-05.09:31:23.467>
actor = 'Stephen.White'
assignee = 'none'
closed = True
closed_date = <Date 2011-06-29.14:51:38.004>
closer = 'orsenthil'
components = ['Library (Lib)']
creation = <Date 2011-06-28.13:37:28.137>
creator = 'jonsiddle'
dependencies = []
files = []
hgrepos = []
issue_num = 12431
keywords = []
message_count = 4.0
messages = ['139361', '139370', '139423', '139837']
nosy_count = 4.0
nosy_names = ['orsenthil', 'Stephen.White', 'santoso.wijaya', 'jonsiddle']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue12431'
versions = ['Python 2.7']

@jonsiddle
Copy link
Mannequin Author

jonsiddle mannequin commented Jun 28, 2011

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()

@jonsiddle jonsiddle mannequin added the type-bug An unexpected behavior, bug, or error label Jun 28, 2011
@santosowijaya
Copy link
Mannequin

santosowijaya mannequin commented Jun 28, 2011

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'

@santosowijaya santosowijaya mannequin added the stdlib Python modules in the Lib dir label Jun 28, 2011
@orsenthil
Copy link
Member

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.

@StephenWhite
Copy link
Mannequin

StephenWhite mannequin commented Jul 5, 2011

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.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant