[Patches] [ python-Patches-1762940 ] struni: test_urllib2, test_cookielib

SourceForge.net noreply at sourceforge.net
Sun Jul 29 20:25:16 CEST 2007


Patches item #1762940, was opened at 2007-07-29 01:12
Message generated for change (Comment added) made by jcgregorio
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1762940&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Tests
Group: Python 3000
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Joe Gregorio (jcgregorio)
Assigned to: Nobody/Anonymous (nobody)
Summary: struni: test_urllib2, test_cookielib

Initial Comment:
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.


----------------------------------------------------------------------

>Comment By: Joe Gregorio (jcgregorio)
Date: 2007-07-29 18:25

Message:
Logged In: YES 
user_id=81604
Originator: YES

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

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1762940&group_id=5470


More information about the Patches mailing list