You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Python 2.7.1+ (default, Apr 6 2011, 16:25:38) [MSC v.1500 32 bit (Intel)] on wi
n32
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib2
[74578 refs]
>>> fp = urllib2.urlopen('http://16.foobnix-cms.appspot.com/test_base')
[75643 refs]
>>> fp.geturl()
"http://16.foobnix-cms.appspot.com/test_redirect#json={value:'OK'}"
[75645 refs]
I'm attaching patches with the appropriate unittest for the redirected case, though.
python-dev commented on Apr 12, 2011
python-devmannequin
Mannequin
More actions
New changeset 3f240a1cd245 by Senthil Kumaran in branch '3.1':
Fix bpo-11703 - urllib2.geturl() does not return correct url when the original url contains #fragment. Patch Contribution by Santoso Wijaya. http://hg.python.org/cpython/rev/3f240a1cd245
Activity
IvanIvanenko commentedon Mar 28, 2011
Python 2.6 returns:
"http://docs.python.org/library/urllib.html#OK"
"http://docs.python.org/library/urllib.html#OK"
Python 2.7 returns:
"http://docs.python.org/library/urllib.html#OK"
"http://docs.python.org/library/urllib.html"
2to3 -w test.py
Python 3 returns:
"http://docs.python.org/library/urllib.html"
"http://docs.python.org/library/urllib.html"
I expect geturl() result with "#OK" in all cases
santosowijaya commentedon Mar 29, 2011
This is because the Request class' constructor splits the URL into __original and fragment:
And the construction of object that urlopen() returns has its geturl() returns the request object's __original field (by now, minus the fragment).
santosowijaya commentedon Mar 29, 2011
Attaching patches against 2.7 and 3.1 branches.
IvanIvanenko commentedon Mar 30, 2011
Santa4nt, I think you also need to check case with Redirect Response URL:
print urllib2.urlopen("http://16.foobnix-cms.appspot.com/test_base").geturl(/?url=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F%253C%2Fa%253E)
python 2.6 returns OK
http://16.foobnix-cms.appspot.com/test_redirect#json={value:'OK'}
python 2.7 returns KO
http://16.foobnix-cms.appspot.com/test_redirect
santosowijaya commentedon Apr 6, 2011
It already does. ;-)
I'm attaching patches with the appropriate unittest for the redirected case, though.
python-dev commentedon Apr 12, 2011
New changeset 3f240a1cd245 by Senthil Kumaran in branch '3.1':
Fix bpo-11703 - urllib2.geturl() does not return correct url when the original url contains #fragment. Patch Contribution by Santoso Wijaya.
http://hg.python.org/cpython/rev/3f240a1cd245
orsenthil commentedon Apr 12, 2011
It should be noted that the bug surfaced in 2.7 and above due to changes made as part of bpo-8280.
python-dev commentedon Apr 12, 2011
New changeset 6e73f75ee034 by Senthil Kumaran in branch '2.7':
Fix bpo-11703 - urllib2.get_url does not handle fragment in url properly.
http://hg.python.org/cpython/rev/6e73f75ee034
orsenthil commentedon Apr 12, 2011
This is fixed in all the codelines. Thanks for the patch, Santoso.
python-dev commentedon Apr 13, 2011
New changeset 8ee48ec69844 by Senthil Kumaran in branch '3.1':
Update the News for the fix to bpo-11703.
http://hg.python.org/cpython/rev/8ee48ec69844
python-dev commentedon Apr 13, 2011
New changeset 502bb809b03b by Senthil Kumaran in branch '2.7':
update news in 2.7 for Issue bpo-11703
http://hg.python.org/cpython/rev/502bb809b03b