[Python-checkins] CVS: python/dist/src/Lib pickle.py,1.49,1.50
Guido van Rossum
gvanrossum@users.sourceforge.net
Fri, 17 Aug 2001 11:49:54 -0700
- Previous message: [Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.226,2.227 compile.c,2.217,2.218 getargs.c,2.61,2.62 marshal.c,1.64,1.65 modsupport.c,2.57,2.58 pythonrun.c,2.146,2.147 sysmodule.c,2.91,2.92
- Next message: [Python-checkins] CVS: python/dist/src/Lib __future__.py,1.8,1.9
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv32109
Modified Files:
pickle.py
Log Message:
Address SF #451547. The approach is a bit draconian: any object that
is pickled as a global must now exist by the name under which it is
pickled, otherwise the pickling fails. Previously, such things would
fail on unpickling, or unpickle as the wrong global object. I'm
hoping that this won't break existing code that is playing tricks with
this.
I need a volunteer to do this for cPickle too.
Index: pickle.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pickle.py,v
retrieving revision 1.49
retrieving revision 1.50
diff -C2 -d -r1.49 -r1.50
*** pickle.py 2001/08/02 04:15:00 1.49
--- pickle.py 2001/08/17 18:49:52 1.50
***************
*** 498,501 ****
--- 498,515 ----
module = whichmodule(object, name)
+ try:
+ __import__(module)
+ mod = sys.modules[module]
+ klass = getattr(mod, name)
+ except (ImportError, KeyError, AttributeError):
+ raise PicklingError(
+ "Can't pickle %r: it's not found as %s.%s" %
+ (object, module, name))
+ else:
+ if klass is not object:
+ raise PicklingError(
+ "Can't pickle %r: it's not the same object as %s.%s" %
+ (object, module, name))
+
memo_len = len(memo)
write(GLOBAL + module + '\n' + name + '\n' +
- Previous message: [Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.226,2.227 compile.c,2.217,2.218 getargs.c,2.61,2.62 marshal.c,1.64,1.65 modsupport.c,2.57,2.58 pythonrun.c,2.146,2.147 sysmodule.c,2.91,2.92
- Next message: [Python-checkins] CVS: python/dist/src/Lib __future__.py,1.8,1.9
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]