[Python-Dev] On breaking modules into packages Was: [issue10199] Move Demo/turtle under Lib/ (original) (raw)
Eric Smith eric at trueblade.com
Wed Nov 3 15:53:11 CET 2010
- Previous message: [Python-Dev] On breaking modules into packages Was: [issue10199] Move Demo/turtle under Lib/
- Next message: [Python-Dev] On breaking modules into packages Was: [issue10199] Move Demo/turtle under Lib/
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 11/3/10 10:16 AM, Michael Foord wrote:
On 03/11/2010 14:05, Nick Coghlan wrote:
On Wed, Nov 3, 2010 at 9:32 AM, Raymond Hettinger <raymond.hettinger at gmail.com> 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...
Actually I think the answer is "no" (assuming you could pickle a TestCase). Here's an example with TestLoader:
$ python27 Python 2.7.0+ (release27-maint:85878, Oct 28 2010, 06:40:25) [GCC 4.1.2 20070626 (Red Hat 4.1.2-13)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
import unittest x = unittest.TestLoader() import pickle pickle.dumps(x) 'ccopy_reg\n_reconstructor\np0\n(cunittest.loader\nTestLoader\np1\nc__builtin__\nobject\np2\nNtp3\nRp4\n.'
$ python24 Python 2.4.4 (#1, Oct 23 2006, 13:58:00) [GCC 4.1.1 20061011 (Red Hat 4.1.1-30)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
import pickle
pickle.loads('ccopy_reg\n_reconstructor\np0\n(cunittest.loader\nTestLoader\np1\nc__builtin__\nobject\np2\nNtp3\nRp4\n.') Traceback (most recent call last): File "", line 1, in ? File "/usr/lib/python2.4/pickle.py", line 1394, in loads return Unpickler(file).load() File "/usr/lib/python2.4/pickle.py", line 872, in load dispatchkey File "/usr/lib/python2.4/pickle.py", line 1104, in load_global klass = self.find_class(module, name) File "/usr/lib/python2.4/pickle.py", line 1138, in find_class import(module) ImportError: No module named loader
The problem is that there is no unittest.loader in 2.4, and unittest.loader.TestLoader is the name that the 2.7 pickle creates. We see this problem every time we try and move anything in the stdlib.
-- Eric.
- Previous message: [Python-Dev] On breaking modules into packages Was: [issue10199] Move Demo/turtle under Lib/
- Next message: [Python-Dev] On breaking modules into packages Was: [issue10199] Move Demo/turtle under Lib/
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]