Message76200
| Author |
kfitch |
| Recipients |
kfitch |
| Date |
2008年11月21日.20:20:45 |
| SpamBayes Score |
3.5781317e-10 |
| Marked as misclassified |
No |
| Message-id |
<1227298848.26.0.43954537451.issue4380@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
from functools import partial
from copy import deepcopy
p = partial("Hello world".replace, "world")
p("mom")
p2 = deepcopy(p)
The output I get is:
Hello mom
Followed by:
<type 'exceptions.TypeError'> Traceback (most recent call last)
/home/kfitch/<ipython console> in <module>()
/usr/lib/python2.5/copy.py in deepcopy(x, memo, _nil)
187 raise Error(
188 "un(deep)copyable object of type
%s" % cls)
--> 189 y = _reconstruct(x, rv, 1, memo)
190
191 memo[d] = y
/usr/lib/python2.5/copy.py in _reconstruct(x, info, deep, memo)
320 if deep:
321 args = deepcopy(args, memo)
--> 322 y = callable(*args)
323 memo[id(x)] = y
324 if listiter is not None:
/usr/lib/python2.5/copy_reg.py in __newobj__(cls, *args)
90
91 def __newobj__(cls, *args):
---> 92 return cls.__new__(cls, *args)
93
94 def _slotnames(cls):
<type 'exceptions.TypeError'>: type 'partial' takes at least one argument
I am not entirely convinced that doing a deepcopy on a partial makes
sense, but I would expect one of:
1) An explicit exception saying it isn't allowed
2) Returning the original partial object
3) An actual copy (should the arguments its storing get deepcopied?)
P.S. This is with 2.5.2 under Linux (Ubuntu 8.04) |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2008年11月21日 20:20:48 | kfitch | set | recipients:
+ kfitch |
| 2008年11月21日 20:20:48 | kfitch | set | messageid: <1227298848.26.0.43954537451.issue4380@psf.upfronthosting.co.za> |
| 2008年11月21日 20:20:47 | kfitch | link | issue4380 messages |
| 2008年11月21日 20:20:45 | kfitch | create |
|