Issue1144636
Created on 2005-02-20 02:48 by jjlee, last changed 2007-02-14 21:43 by jjlee.
| File name |
Uploaded |
Description |
Edit |
Remove |
|
pickleable.diff
|
jjlee,
2005-02-20 02:48
|
|
|
|
|
msg47823 - (view) |
Author: John J Lee (jjlee) |
Date: 2005-02-20 02:48 |
|
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.
|
|
msg47824 - (view) |
Author: John J Lee (jjlee) |
Date: 2005-03-04 18:46 |
|
Logged In: YES
user_id=261020
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.
|
|
msg47825 - (view) |
Author: Martin v. Löwis (loewis) |
Date: 2007-02-14 10:27 |
|
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 one:
def test_1144636(self):
# Make sure OpenerDirector instances can be pickled
import pickle
try:
pickle.dumps(urllib2.build_opener())
except pickle.PicklingError:
self.fail("cannot pickle OpenerDirector instances")
|
|
msg47826 - (view) |
Author: John J Lee (jjlee) |
Date: 2007-02-14 21:43 |
|
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 subtypes
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 request)
|
|
| Date |
User |
Action |
Args |
| 2005-02-20 02:48:45 | jjlee | create | |
|