[求助]deepcopy 一个定义了__new__()的对象时出错
代码:程序代码:
class Test( object ): "" def __new__( cls, x, **args ): return object.__new__( cls ) r0 = Test( 4 ) from copy import deepcopy r = deepcopy( r0 )
报错:
r = deepcopy( r0 )
File "D:\Python25\lib\copy.py", line 189, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "D:\Python25\lib\copy.py", line 322, in _reconstruct
y = callable(*args)
File "D:\Python25\lib\copy_reg.py", line 92, in __newobj__
return cls.__new__(cls, *args)
TypeError: __new__() takes exactly 2 arguments (1 given)
这是怎么回事?
经测试,__new__( cls, **args ) 这样就可以。多一个参数就不行。