[issue1515] deepcopy doesn't copy instance methods

2009-11-28 Thread Antoine Pitrou
Antoine Pitrou added the comment: The patch has been committed in r76571 (trunk) and r76572 (py3k). Thank you! -- resolution: accepted -> fixed stage: -> committed/rejected status: open -> closed ___ Python tracker

[issue1515] deepcopy doesn't copy instance methods

2009-11-28 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: Guido - agreed! Versions updated. -- versions: +Python 3.2 -Python 2.6 ___ Python tracker ___ ___

[issue1515] deepcopy doesn't copy instance methods

2009-11-27 Thread Guido van Rossum
Guido van Rossum added the comment: Smells like a feature to me. "Bug" == "coding error" "Feature" == "change in (documented or intended) behavior" I'm fine with this going into 2.7 / 3.2. -- ___ Python tracker

[issue1515] deepcopy doesn't copy instance methods

2009-11-27 Thread Robert Collins
Robert Collins added the comment: Oh man, I looked for a regular unit test - sorry that I missed it. Bah. I've added a call to the method and moved it into test_copy. -- Added file: http://bugs.python.org/file15406/issue1515.patch ___ Python tracker

[issue1515] deepcopy doesn't copy instance methods

2009-11-27 Thread Antoine Pitrou
Antoine Pitrou added the comment: > @Antoine, I agree that the tests for copy should be a proper unit test; > that seems orthogonal to this patch though :) Not really, since Lib/test/test_copy.py exists and contains tests for deepcopy; you should add the new test there. > I don't have a checko

[issue1515] deepcopy doesn't copy instance methods

2009-11-27 Thread Robert Collins
Robert Collins added the comment: @Antoine, I agree that the tests for copy should be a proper unit test; that seems orthogonal to this patch though :) I don't have a checkout of 3 at the moment, but do you think the test failure on 3 is shallow or deep? -- ___

[issue1515] deepcopy doesn't copy instance methods

2009-11-27 Thread Antoine Pitrou
Antoine Pitrou added the comment: The test should be a real unittest in Lib/test/test_copy, not something in the __main__ section of Lib/copy.py. Nobody runs these, as a matter of fact if you run Lib/copy.py under the py3k branch it fails. To nitpick a bit, I also think Michael's test above was

[issue1515] deepcopy doesn't copy instance methods

2009-11-27 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: Robert's patch looks fine to me. My concern is changing this in a point release (e.g. 2.6.5). I know Guido said he was fine for this going into 2.6 but that was in January 08, before 2.6 final was released in October 08. At this point, the question is whethe

[issue1515] deepcopy doesn't copy instance methods

2009-11-27 Thread Robert Collins
Robert Collins added the comment: This affects 2.7 too. -- versions: +Python 2.7 ___ Python tracker ___ ___ Python-bugs-list mailing l

[issue1515] deepcopy doesn't copy instance methods

2009-11-27 Thread Robert Collins
Robert Collins added the comment: Ran into this trying to do some test isolation stuff. Notwithstanding the questions about 'why', this is a clear limitation hat can be solved quite simply - is there any harm that will occur if we fix it? I've attached a patch, with a test (in the style of the

[issue1515] deepcopy doesn't copy instance methods

2009-11-25 Thread Ram Rachum
Ram Rachum added the comment: (I see some time has passed since the last message. I'm assuming the issue wasn't fixed, correct me if I'm wrong.) Here's a use case for using deepcopy: I'm developing a simulations framework called GarlicSim, all Python. You can see a short video here: http://g

[issue1515] deepcopy doesn't copy instance methods

2008-01-31 Thread Guido van Rossum
Guido van Rossum added the comment: On Jan 31, 2008 2:54 PM, Michael Van Biesbrouck wrote: > Why do people want to use copy and deepcopy? I think that the issue is > that Python is an imperative language that passes and copies references. > If a library function doesn't treat its arguments as c

[issue1515] deepcopy doesn't copy instance methods

2008-01-31 Thread Michael Van Biesbrouck
Michael Van Biesbrouck added the comment: Dmitrey: You can't call _deepcopy_method() on anything other than something with type types.MethodType. It is a function in a type-dispatch table, so it will always be called safely. copy._deepcopy_dispatch is that table; if you assign _deepcopy_method

[issue1515] deepcopy doesn't copy instance methods

2008-01-31 Thread Dmitrey
Dmitrey added the comment: I don't know did you mean it to me (as I've noticed from address) or no. I can hardly provide any help for fixing the bug, I'm not skilled enough in Python core files. Here's results of the proposition mentioned: import copy import types def _deepcopy_method(x, memo

[issue1515] deepcopy doesn't copy instance methods

2008-01-31 Thread Christian Heimes
Christian Heimes added the comment: Since Guido accepted the proposal can you please provide a patch with at least one unit test? -- resolution: -> accepted __ Tracker <[EMAIL PROTECTED]> ___

[issue1515] deepcopy doesn't copy instance methods

2008-01-31 Thread Guido van Rossum
Guido van Rossum added the comment: I'm fine with applying Michael's suggestion to 2.6. I're reverting the priority change though; using deepcopy is not OO and IMO usually indicates that there's something wrong with your app. -- severity: major -> normal ___

[issue1515] deepcopy doesn't copy instance methods

2008-01-31 Thread Christian Heimes
Christian Heimes added the comment: I'm bumping up the version number to 2.6. Python 2.5 is in maintenance mode and the behavior of deepcopy for instance methods won't be changed. -- components: +Library (Lib) priority: -> normal versions: +Python 2.6 -Python 2.5 __

[issue1515] deepcopy doesn't copy instance methods

2008-01-31 Thread Christian Heimes
Christian Heimes added the comment: I've read your blog. You don't have to modify the Python core: import copy import types def _deepcopy_method(x, memo): return type(x)(x.im_func, deepcopy(x.im_self, memo), x.im_class) copy._deepcopy_dispatch[types.MethodType] = _deepcopy_method I still w

[issue1515] deepcopy doesn't copy instance methods

2008-01-31 Thread Dmitrey
Dmitrey added the comment: Hallo, I' developer of the OpenOpt, free Python-based numerical optimization framework. Please don't you mind me to increase Severity of the bug to major. This bug is driving me mad, as well as some of OO users, and makes OO usage much less convenient and obvious. ht

[issue1515] deepcopy doesn't copy instance methods

2008-01-07 Thread Michael Van Biesbrouck
Michael Van Biesbrouck added the comment: Guido pointed out a common use case where people use bound methods in a way that would be poorly served by my change. An alternate implementation with a deeper copy will cause less surprise: def _deepcopy_method(x, memo): return type(x)(x.im_func, d

[issue1515] deepcopy doesn't copy instance methods

2007-12-19 Thread Guido van Rossum
Guido van Rossum added the comment: I'll take this off line. __ Tracker <[EMAIL PROTECTED]> __ ___ Python-bugs-list mailing list Unsubscribe: http://ma

[issue1515] deepcopy doesn't copy instance methods

2007-12-19 Thread Michael Van Biesbrouck
Michael Van Biesbrouck added the comment: I am implementing a library that makes extensive use of delayed executions represented by functions. Copying objects both with and without shared state referenced by the functions is important. There is one entry point where I would expect functions to

[issue1515] deepcopy doesn't copy instance methods

2007-12-19 Thread Guido van Rossum
Guido van Rossum added the comment: I disagree that this would be harmless; this was excluded intentionally. A (bound) method contains an instance which definitely represents state and calling the method can easily mutate that state. This is different from classes (which could contain state) or

[issue1515] deepcopy doesn't copy instance methods

2007-11-28 Thread Michael Van Biesbrouck
New submission from Michael Van Biesbrouck: Currently, using deepcopy on instance methods causes an exception to be thrown. This can be fixed by adding one line to copy.py: d[types.MethodType] = _deepcopy_atomic This will not make duplicate copies of mutable values referenced within the instan