[wwwsearch-commits] r23247 - wwwsearch/mechanize/trunk/mechanize

jjlee at codespeak.net jjlee at codespeak.net
Sun Feb 12 03:49:16 CET 2006


Author: jjlee
Date: Sun Feb 12 03:49:14 2006
New Revision: 23247

Modified:
   wwwsearch/mechanize/trunk/mechanize/_useragent.py
Log:
Don't use cookielib, to avoid having to work around Python 2.4 RFC 2109 bug, and to avoid my braindead thread synchronisation code in cookielib :-((((( (I haven't encountered specific breakage due to latter, but since it's braindead I may as well avoid it)

Modified: wwwsearch/mechanize/trunk/mechanize/_useragent.py
==============================================================================
--- wwwsearch/mechanize/trunk/mechanize/_useragent.py	(original)
+++ wwwsearch/mechanize/trunk/mechanize/_useragent.py	Sun Feb 12 03:49:14 2006
@@ -16,22 +16,8 @@
 import ClientCookie
 if sys.version_info[:2] >= (2, 4):
     from urllib2 import OpenerDirector, BaseHandler, HTTPErrorProcessor
-    if sys.version_info[:2] == (2, 4):
-        # Workaround for RFC 2109 bug http://python.org/sf/1157027 (at least if
-        # you don't pass your own CookieJar in: if that's the case, you should
-        # pass rfc2965=True to the DefaultCookiePolicy constructor yourself, or
-        # set the corresponding attribute).
-        import cookielib
-        class SaneHTTPCookieProcessor(urllib2.HTTPCookieProcessor):
-            def __init__(self, cookiejar=None):
-                if cookiejar is None:
-                    cookiejar = cookielib.CookieJar(
-                        cookielib.DefaultCookiePolicy(rfc2965=True))
-                self.cookiejar = cookiejar
-        HTTPCookieProcessor = SaneHTTPCookieProcessor
 else:
-    from ClientCookie import OpenerDirector, BaseHandler, HTTPErrorProcessor, \
-         HTTPCookieProcessor
+    from ClientCookie import OpenerDirector, BaseHandler, HTTPErrorProcessor
 
 class HTTPRefererProcessor(BaseHandler):
     def http_request(self, request):
@@ -85,7 +71,7 @@
         "_authen": urllib2.HTTPBasicAuthHandler,
         # XXX rest of authentication stuff
         "_redirect": ClientCookie.HTTPRedirectHandler,
-        "_cookies": HTTPCookieProcessor,
+        "_cookies": ClientCookie.HTTPCookieProcessor,
         "_refresh": ClientCookie.HTTPRefreshProcessor,
         "_referer": HTTPRefererProcessor,  # from this module, note
         "_equiv": ClientCookie.HTTPEquivProcessor,


More information about the wwwsearch-commits mailing list