Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue1515] deepcopy doesn't copy instance methods

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Nov 25, 2009, 4:12 AM

Post #1 of 11 (449 views)
Permalink
[issue1515] deepcopy doesn't copy instance methods

Ram Rachum <cool-rr [at] cool-rr> 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://garlicsim.org/brief_introduction.html
The program handles world states in simulated worlds. Some simpacks
deepcopy the existing world state to generate the next world state.

This bug is currently preventing me from writing simpacks whose world
states reference instance methods, which is a severe limitation for me.

I think this issue should be bumped in priority. Also, in the mean time,
a more informative error message should be given (Like "deepcopy can't
handle instance methods."), instead of the current cryptic one.

----------
nosy: +cool-RR

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue1515>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 27, 2009, 1:54 AM

Post #2 of 11 (407 views)
Permalink
[issue1515] deepcopy doesn't copy instance methods [In reply to]

Robert Collins <robertc [at] robertcollins> 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 current tests)
which shows the copy works correctly.

----------
keywords: +patch
nosy: +rbcollins
Added file: http://bugs.python.org/file15405/issue1515.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue1515>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 27, 2009, 1:55 AM

Post #3 of 11 (406 views)
Permalink
[issue1515] deepcopy doesn't copy instance methods [In reply to]

Robert Collins <robertc [at] robertcollins> added the comment:

This affects 2.7 too.

----------
versions: +Python 2.7

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue1515>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 27, 2009, 5:39 AM

Post #4 of 11 (408 views)
Permalink
[issue1515] deepcopy doesn't copy instance methods [In reply to]

Barry A. Warsaw <barry [at] python> 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 whether this is safe to change in a
patch release or whether this needs to go in 2.7.

Probably a question for python-dev.

----------
nosy: +barry

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue1515>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 27, 2009, 5:47 AM

Post #5 of 11 (409 views)
Permalink
[issue1515] deepcopy doesn't copy instance methods [In reply to]

Antoine Pitrou <pitrou [at] free> 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 better, since it
was checking whether the copied method actually worked.

----------
nosy: +pitrou

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue1515>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 27, 2009, 2:25 PM

Post #6 of 11 (403 views)
Permalink
[issue1515] deepcopy doesn't copy instance methods [In reply to]

Robert Collins <robertc [at] robertcollins> 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?

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue1515>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 27, 2009, 2:40 PM

Post #7 of 11 (406 views)
Permalink
[issue1515] deepcopy doesn't copy instance methods [In reply to]

Antoine Pitrou <pitrou [at] free> 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 checkout of 3 at the moment, but do you think the test
> failure on 3 is shallow or deep?

What I mean is that Lib/copy.py fails without your changes under py3k.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue1515>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 27, 2009, 3:05 PM

Post #8 of 11 (401 views)
Permalink
[issue1515] deepcopy doesn't copy instance methods [In reply to]

Robert Collins <robertc [at] robertcollins> 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 <report [at] bugs>
<http://bugs.python.org/issue1515>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 27, 2009, 6:01 PM

Post #9 of 11 (404 views)
Permalink
[issue1515] deepcopy doesn't copy instance methods [In reply to]

Guido van Rossum <guido [at] python> 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 <report [at] bugs>
<http://bugs.python.org/issue1515>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 28, 2009, 7:45 AM

Post #10 of 11 (396 views)
Permalink
[issue1515] deepcopy doesn't copy instance methods [In reply to]

Barry A. Warsaw <barry [at] python> added the comment:

Guido - agreed! Versions updated.

----------
versions: +Python 3.2 -Python 2.6

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue1515>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 28, 2009, 7:59 AM

Post #11 of 11 (395 views)
Permalink
[issue1515] deepcopy doesn't copy instance methods [In reply to]

Antoine Pitrou <pitrou [at] free> 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 <report [at] bugs>
<http://bugs.python.org/issue1515>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.