[issue14577] pickling uses __class__ so you can't pickle proxy/mock objects that pretend to be other objects

2012-04-14 Thread Michael Foord
Michael Foord added the comment: Nick - in general proxy objects have a *reference* to their target (weakref being somewhat of a special case), and pickle can already handle multiple references to the same target when deserializing an object graph. So I don't see that argument holding water f

[issue14577] pickling uses __class__ so you can't pickle proxy/mock objects that pretend to be other objects

2012-04-14 Thread Nick Coghlan
Nick Coghlan added the comment: Some additional thoughts for anyone else that comes across this issue. Consider the case of a weakref proxy (the only proxy type in the stdlib): for that, you never want to serialise the proxy, you want to serialise the original object. To correctly serialise

[issue14577] pickling uses __class__ so you can't pickle proxy/mock objects that pretend to be other objects

2012-04-14 Thread Michael Foord
Changes by Michael Foord : -- resolution: -> wont fix stage: -> committed/rejected status: open -> closed ___ Python tracker ___ ___

[issue14577] pickling uses __class__ so you can't pickle proxy/mock objects that pretend to be other objects

2012-04-14 Thread Michael Foord
Michael Foord added the comment: test_pickle still passes with only copyreg.py modified. With one additional change in pickle.py (line 405 to use type(obj) instead of obj.__class__) the pickling works as I would hope (I would need assistance to fix _pickle): >>> import sys [65446 refs] >>>

[issue14577] pickling uses __class__ so you can't pickle proxy/mock objects that pretend to be other objects

2012-04-14 Thread Michael Foord
Michael Foord added the comment: So, changing copyreg.py to use type(self) instead of self.__class__ isn't sufficient. _pickle accesses __class__ as well it seems. However I'm running all tests with this change in place to see if it breaks intended behaviour: Python 3.3.0a1+ (default:51016ff

[issue14577] pickling uses __class__ so you can't pickle proxy/mock objects that pretend to be other objects

2012-04-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: Have you tried making a change and see if any tests fail? This is a behaviour change and I wonder if the original behaviour is by design or accident. -- components: +Library (Lib) nosy: +alexandre.vassalotti, pitrou type: -> enhancement versions: +Pyt

[issue14577] pickling uses __class__ so you can't pickle proxy/mock objects that pretend to be other objects

2012-04-14 Thread Michael Foord
New submission from Michael Foord : Pickling uses __class__ instead of type(obj) to determine the type to pickle. This means that objects which pretend to be other objects (like proxy and mock objects) can't be pickled correctly: >>> class Foo(object): ... __class__ = property(lambda *a, **k: