[Patches] [ python-Patches-1144636 ] Make urllib2.OpenerDirector instances pickle-able

SourceForge.net noreply at sourceforge.net
Wed Feb 14 22:43:21 CET 2007

Patches item #1144636, was opened at 2005-02-20 02:48
Message generated for change (Comment added) made by jjlee
You can respond by visiting: 

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: Library (Lib)
Group: Python 2.5
>Status: Closed
Resolution: None
Priority: 5
Private: No
Submitted By: John J Lee (jjlee)
Assigned to: Nobody/Anonymous (nobody)
Summary: Make urllib2.OpenerDirector instances pickle-able

Initial Comment:
urllib2.OpenerDirector would be pickleable if it were
not for the fact that a couple of urllib2 handlers
(which build_opener() adds by default) have function
instance attributes.

It's trivial to replace these instance attributes with
a method that delegates to the appropriate function,
thus allowing pickling.


>Comment By: John J Lee (jjlee)
Date: 2007-02-14 21:43

Logged In: YES 
Originator: YES

I am no longer convinced that the intended change is an improvement, so I
am closing this tracker item.

FWIW, mysteriously, your unit test always *passes* for me (both before and
after applying the patch).  (And before svn updating from roughly rev
53200, your unit test fails for me before applying the patch, and passes
for me after applying the patch.)

For the record, the reasons I'm no longer convinced that pickle-ability of
urllib2.OpenerDirector instances is a good thing are:

1. I don't think a pickle-ability constraint should be imposed on

2. I'm not convinced now that the ability to pickle these instances is
terribly useful (although I did file the patch as a result of a user


Comment By: Martin v. Löwis (loewis)
Date: 2007-02-14 10:27

Logged In: YES 
Originator: NO

The patch doesn't fix the problem; the opener remains unpicklable. If you
are still interested in this patch, please revise it accordingly; if not,
please close it. When you revise it, please include a test case, like this

    def test_1144636(self):
        # Make sure OpenerDirector instances can be pickled
        import pickle
        except pickle.PicklingError:
            self.fail("cannot pickle OpenerDirector instances")


Comment By: John J Lee (jjlee)
Date: 2005-03-04 18:46

Logged In: YES 

Hmm, maybe this fault (can't pickle) will be fixed without
need for this patch in 2.5, due to the change to unbound
methods that was discussed on python-dev.  I don't
understand that issue, so I can't say.


You can respond by visiting: 

More information about the Patches mailing list