summaryrefslogtreecommitdiffstats
path: root/Lib/pickle.py
Commit message (Collapse)AuthorAgeFilesLines
* Fix Bug #114293:Jeremy Hylton2000-09-151-1/+41
| | | | | | | | | | | Strings are unpickled by calling eval on the string's repr. This change makes pickle work like cPickle; it checks if the pickled string is safe to eval and raises ValueError if it is not. test suite modifications: Verify that pickle catches a variety of insecure string pickles Make test_pickle and test_cpickle use exactly the same test suite Add test for pickling recursive object
* Change string exceptions to class exceptions.Guido van Rossum2000-06-291-2/+3
|
* Marc-Andre Lemburg: support pickling Unicode objects, both in textGuido van Rossum2000-03-101-0/+28
| | | | mode ('V') and in binary mode ('X').
* More trivial comment -> docstring transformations by Ka-Ping Yee,Guido van Rossum2000-02-041-1/+1
| | | | | | | | | | | | | | | | | | who writes: Here is batch 2, as a big collection of CVS context diffs. Along with moving comments into docstrings, i've added a couple of missing docstrings and attempted to make sure more module docstrings begin with a one-line summary. I did not add docstrings to the methods in profile.py for fear of upsetting any careful optimizations there, though i did move class documentation into class docstrings. The convention i'm using is to leave credits/version/copyright type of stuff in # comments, and move the rest of the descriptive stuff about module usage into module docstrings. Hope this is okay.
* Jeremy writes:Guido van Rossum1999-10-101-1/+2
| | | | | | | | I found the following patch helpful in tracking down a bug in some code. I had appended time, the module, instead of time.time(). Not sure if it is generally true that printing the repr of the object is good, but I expect that most unpicklable things will have fairly information and concise reprs (like files or sockets or modules).
* Don't use "exec" in find_class(). It's slow, unnecessary, and (as AMKGuido van Rossum1999-03-251-5/+4
| | | | points out) it doesn't work in JPython Applets.
* Jim Fulton writes:Guido van Rossum1998-10-221-13/+16
| | | | | | | | | | | | """ I've attached a long overdue patch to pickle.py to bring it to format 1.3, which is the same as 1.2 except that the binary float format is supported. This is done using the new platform-indepent format features of struct. This patch also gets rid of the undocumented obsolete Pickler dump_special method. """
* In load_inst(), when instantiating an instance the old way (i.e. whenGuido van Rossum1998-09-151-4/+7
| | | | | | | there's an __getinitargs__() method), if a TypeError occurs, catch and reraise it but add info to the error about the class name being instantiated. This makes debugging a lot easier if __getinitargs__() returns something bogus (e.g. a string instead of a singleton tuple).
* add handler for JPython's org.python.core.PyStringMap object, whichJeremy Hylton1998-05-271-0/+7
| | | | walks and quacks like a dictionary.
* Whoops! Add a missing 'instantiated = 1' to load_inst(); otherwise itGuido van Rossum1998-04-131-0/+1
| | | | would still try to call the class...
* Correct dumb typo found by kjpylint (stack should be self.stack).Guido van Rossum1998-03-311-1/+1
|
* Correct a definite typo ('mem' should be 'memo').Guido van Rossum1998-03-311-1/+1
|
* Mass check-in after untabifying all files that need it.Guido van Rossum1998-03-261-72/+72
|
* Fixed typo in docstring: "__ version__" --> "__version__"Fred Drake1998-02-131-1/+1
|
* Unpickler.load_inst(), Unpickler.load_obj(), Unpickler.load_build():Barry Warsaw1998-01-261-7/+28
| | | | | | | | | | | | Fixed problems when unpickling in restricted execution environments. These methods try to assign to an instance's __class__ attribute, or access the instances __dict__, which are prohibited in REE. For the first two methods, I re-implemented the old behavior when assignment to value.__class__ fails. For the load_build() I also re-implemented the old behavior when inst.__dict__.update() fails but this means that unpickling in REE is semantically different than unpickling in unrestricted mode.
* Jim Fulton writes:Guido van Rossum1997-12-101-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | The attached patch adds the following behavior to the handling of REDUCE codes: - A user-defined type may have a __reduce__ method that returns a string rather than a tuple, in which case the object is saved as a global object with a name given by the string returned by reduce. This was a feature added to cPickle a long time ago. - User-defined types can now support unpickling without executing a constructor. The second value returned from '__reduce__' can now be None, rather than an argument tuple. On unpickling, if the second value returned from '__reduce__' during pickling was None, then rather than calling the first value returned from '__reduce__', directly, the '__basicnew__' method of the first value returned from '__reduce__' is called without arguments. I also got rid of a few of Chris' extra ()s, which he used to make python ifs look like C ifs.
* Don't specify base 0 to string.atoi when unpickling integers in textGuido van Rossum1997-12-101-1/+1
| | | | | | mode. The pickler always uses base 10 so the default base should be fine. (The base gets us in trouble when there's no strop module, as the atoi() in string.py only supports base 10. This is for JPython.)
* When instantiating a class with no arguments and where the class doesGuido van Rossum1997-12-051-135/+40
| | | | | | | | | | | not define __getinitargs__, bypass the __init__ constructor completely. This uses the trick of instantiating an empty dummy class and then changing inst.__class__ to the real class. This is done in two places: once for the INST and once for the OBJ format code. Also replaced the much outdated long doc string with a short summary of the module; the information of that doc string is already incorporated in the library reference manual.
* Three independent changes:Guido van Rossum1997-09-121-5/+10
| | | | | | | | | - Don't use "from copy_reg import *". - Use cls.__module__ instead of calling whichobject(cls, cls.__name__); also try __module__ in whichmodule(), just in case. - After calling save_reduce(), add the object to the memo.
* *Semantic change*: when unpickling the instance variables of anGuido van Rossum1997-09-081-2/+1
| | | | | | | | | | instance, use inst.__dict__.update(value) instead of a for loop with setattr() over the value.keys(). This is more consistent (the pickling doesn't use getattr() either but pickles inst.__dict__) and avoids problems with instances that have a __setattr__ hook. But it *is* a semantic change (because the setattr hook is no longer used). So beware!
* Add the same _keep_alive patch (by Michael Scharff) that was added toGuido van Rossum1997-09-031-0/+19
| | | | | copy.deepcopy() a while ago. Can't reproduce this but it doesn't break anything and it looks like the code could have the same problem.
* Restore two features of the original 1.4 pickle:Guido van Rossum1997-04-251-5/+6
| | | | | | - which_module() search __main__ last; - load_inst() no longer checks that the classname really refers to a class.
* Remove Digital Creations copyright (Jim sez it's okay).Guido van Rossum1997-04-111-53/+0
|
* New version by Digital Creations, supports binary format compatibleGuido van Rossum1997-04-091-427/+785
| | | | with cPickle.
* Implement find_class() without exec statement.Guido van Rossum1997-03-141-4/+2
|
* Compromise on test in find_class(): a user-defined function is okay,Guido van Rossum1996-10-071-3/+1
| | | | but a built-in function is not.
* This is the third time I check in this change :-(Guido van Rossum1996-08-081-2/+1
| | | | | Don't use assignments into inst.__dict__ to restore instance variables; use setattr() instead.
* Slight update of doc string -- suggest default args for __init__, noGuido van Rossum1996-08-081-4/+6
| | | | longer complain that __getinitargs__ is an ugly name.
* Optimizations and one intentional loophole by Jim Fulton.Guido van Rossum1996-07-221-58/+82
| | | | | | | | | | The optimizations consist mostly of using local variables to cache methods or instance variables used a lot (e.g. "self.write"). The loopholes allows marshalling extension types as long as they have a __class__ attribute (in which case they may support the rest of the class piclking protocol as well). This allows pickling MESS extension types.
* Set the base for atoi() and atol() to 0, since we're reading PythonGuido van Rossum1996-05-151-3/+3
| | | | | numbers here, and so that atol() doesn't barf on the trailing 'L'. Add a test case involving a long integer.
* Don't atoi() the memo key.Guido van Rossum1996-04-121-7/+16
| | | | Use atoi(), atol(), atof() instead of load_atomic for seed-up.
* correct typo (persis*ent)Guido van Rossum1995-08-071-1/+1
|
* test other name variableGuido van Rossum1995-06-221-1/+1
|
* correct typo in exampleGuido van Rossum1995-04-101-1/+1
|
* pickle classes; add format_version, load(s)/dump(s) shortcutsGuido van Rossum1995-03-141-16/+61
|
* added PicklingError exceptionGuido van Rossum1995-03-091-2/+9
|
* raise EOFError when load() hits EOF, instead of KeyErrorGuido van Rossum1995-03-041-0/+4
|
* minute comment changesGuido van Rossum1995-02-161-3/+3
|
* shelve.py: database of persistent objects, on top of pickle.py and anydbm.pyGuido van Rossum1995-01-101-0/+504
pickle.py: new low-level persistency module (used to be called flatten) dbmac.py: stupid dbm clone for the Mac anydbm.py: generic dbm interface (should be extended to support gdbm)