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: struni: test_urllib2, test_cookielib
Type: Stage:
Components: Tests Versions: Python 3.0
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: gvanrossum, jcgregorio, loewis
Priority: normal Keywords: patch

Created on 2007-07-29 01:12 by jcgregorio, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
urllib2-cookie-quote.patch jcgregorio, 2007-07-29 01:12 Patch for test_urllib2 and test_cookielib
urllib2-cookie-quote-2.patch jcgregorio, 2007-07-29 18:25 Updated patch that folds the closure and Memoize into a single simpler class.
Messages (4)
msg52960 - (view) Author: Joe Gregorio (jcgregorio) * Date: 2007-07-29 01:12
This patch fixes the unit tests of both test_urllib2 and test_cookielib. The reason for combining them is that they both needed the changes to urllib.quote().

The largest part of this patch is to urllib.quote(), which would operate on unicode strings, but only so long as they didn't stray out of the ASCII range. The old code would create a dictionary with 256 entries that mapped incoming chars to their 'safe' replacements, and that dict was created once in its entirety when the function was first called and cached for later calls. Since the incoming character string is now unicode that method won't work. 

The new code does not build the dict in its entirety, instead it memoizes the ASCII range translations as it runs. It does not memoize translations outside of the ASCII range as that would be hole by which you could exhaust a programs memory.
msg52961 - (view) Author: Joe Gregorio (jcgregorio) * Date: 2007-07-29 18:25
This is an updated patch that simplifies the translation of characters. 

Instead of having a closure for the quoting and then wrapping it
in a Memoize instance, this patch just creates a simple
Quoter class that does the translation and caching.

File Added: urllib2-cookie-quote-2.patch
msg52962 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-08-03 19:19
Committed revision 56709.
msg64333 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2008-03-22 18:07
I think the patch was wrong. I question whether urllib *should* work on
str at all, given that URLs are byte strings.

In any case, the quoting is incorrect for str; it should implement rfc
3987, but currently does a mixture of Latin-1 and UTF-8.
History
Date User Action Args
2022-04-11 14:56:25adminsetgithub: 45252
2008-03-22 18:07:45loewissetnosy: + loewis
messages: + msg64333
2008-01-06 22:29:45adminsetkeywords: - py3k
versions: + Python 3.0
2007-07-29 01:12:36jcgregoriocreate