On 03/11/2010 14:26, Michael Foord wrote:
On 03/11/2010 14:17, Antoine Pitrou wrote:
Le mercredi 03 novembre 2010 à 14:16 +0000, Michael Foord a écrit :
On 03/11/2010 14:05, Nick Coghlan wrote:
On Wed, Nov 3, 2010 at 9:32 AM, Raymond Hettinger
<[email protected]> wrote:
Sounds like a decision to split a module into a package is a big
commitment. Each of the individual file names becomes a permanent
part of the API. Even future additional splits are precluded
because it might break someones dotted import (i.e. not a single
function can be moved between those files -- once in
unittest.utils, alway in unittest.utils).
Can Python 2.7 pickles containing unittest classes be unpickled using
2.6 or earlier? Even if nobody uses the new names for imports, I
believe they implicitly end up included in any pickles involving
affected classes (I seem to recall we've been bitten by that before
when moving things around).
Yes, since unittest.TestCase is still available (as are all the names).
I believe so anyway...
unittest.TestCase is not really pickleable. There were
test_multiprocessing issues because of that (see recent SVN checkins).
Interesting. We made some fixes before 2.7 to ensure they were
copyable, but we fixed this in the copy module. TestCase instances now
store some method objects in a dictionary which may make them
unpickleable, so that could be a new problem. I'll test with 2.6 and
2.7 to see.
An easy fix would be to store the method names rather than the method
objects themself (if this is indeed the cause of the problem). This is
what unittest2 does so that it works with earlier versions of Python
that don't have the fix we put in copy.
Yep, looks like 2.7 introduced a bug making it impossible to pickle
TestCase instances. I think it will be easy to fix, I'll create a
specific issue:
$python
Python 2.6.5 (r265:79359, Mar 24 2010, 01:32:55)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from unittest import TestCase
>>> from pickle import dumps
>>> t = TestCase('assert_')
>>> dumps(t)
"ccopy_reg\n_reconstructor\np0\n(cunittest\nTestCase\np1\nc__builtin__\nobject\np2\nNtp3\nRp4\n(dp5\nS'_testMethodDoc'\np6\nS'Fail
the test unless the expression is
true.'\np7\nsS'_testMethodName'\np8\nS'assert_'\np9\nsb."
>>>
bigmac:beta.python.org michael$ python2.7
ActivePython 2.7.0.1 (ActiveState Software Inc.) based on
Python 2.7 (r27:82500, Jul 4 2010, 13:58:56)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from unittest import TestCase
>>> from pickle import dumps
>>> t = TestCase('assert_')
>>> dumps(t)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py",
line 1374, in dumps
Pickler(file, protocol).dump(obj)
...
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py",
line 306, in save
rv = reduce(self.proto)
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy_reg.py",
line 70, in _reduce_ex
raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle instancemethod objects
All the best,
Michael
Michael
Regards
Antoine.
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk
--
http://www.voidspace.org.uk/
READ CAREFULLY. By accepting and reading this email you agree,
on behalf of your employer, to release me from all obligations
and waivers arising from any and all NON-NEGOTIATED agreements,
licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap,
confidentiality, non-disclosure, non-compete and acceptable use
policies (”BOGUS AGREEMENTS”) that I have entered into with your
employer, its partners, licensors, agents and assigns, in
perpetuity, without prejudice to my ongoing rights and privileges.
You further represent that you have the authority to release me
from any BOGUS AGREEMENTS on behalf of your employer.
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com