summaryrefslogtreecommitdiffstats
path: root/Lib/pickle.py
Commit message (Collapse)AuthorAgeFilesLines
...
* Using marshal functions to pack & unpack 1-byte ints is an obscure &Tim Peters2003-01-271-11/+10
| | | | expensive way to spell chr() and ord().
* Added a brief comment to each pickle opcode declaration.Tim Peters2003-01-271-45/+50
|
* Raise PicklingError when __reduce__() fails, andJeremy Hylton2003-01-241-32/+30
| | | | | | | | | | | add memoize() helper function to update the memo. The first element of the tuple returned by __reduce__() must be a callable. If it isn't the Unpickler will raise an error. Catch this error in the pickler and raise the error there. The memoize() helper also has a comment explaining how the memo works. So methods can't use memoize() because the write funny codes.
* Remove inst_persistent_id() WANNI (we ain't never needed it).Jeremy Hylton2002-11-131-15/+6
| | | | Add some simple tests of the persistence hooks.
* Fiddle comments and variable names in whichmodule().Jeremy Hylton2002-09-191-11/+10
|
* whichmodule() should skip dummy package entries in sys.modules.Jeremy Hylton2002-09-191-0/+2
| | | | | | | | This fixes the charming, but unhelpful error message for >>> pickle.dumps(type.__new__) Can't pickle <built-in method __new__ of type object at 0x812a440>: it's not the same object as datetime.math.__new__ Bugfix candidate.
* Patch #505705: Remove eval in pickle and cPickle.Martin v. Löwis2002-08-141-3/+10
|
* Given the persistent id code a shot at a class before calling save_global().Jeremy Hylton2002-07-161-5/+5
| | | | | Some persistent picklers (well, probably, the *only* persistent pickler) would like to pickle some classes in a special way.
* Code modernization. Replace v=s[i]; del s[i] with single lookup v=s.pop(i)Raymond Hettinger2002-06-301-14/+6
|
* SF 563203. Replaced 'has_key()' with 'in'.Raymond Hettinger2002-06-011-4/+4
|
* Remove comment about inheritance, look one line upNeal Norwitz2002-05-301-5/+1
|
* Patch 560023 adding docstrings. 2.2 Candidate (after verifying modules were ↵Raymond Hettinger2002-05-291-3/+69
| | | | not updated after 2.2).
* Whitespace normalization.Tim Peters2002-05-231-1/+1
|
* Patch 533291. Deprecate None return form of __reduce__.Raymond Hettinger2002-05-211-0/+4
|
* Add Pickler.clear_memo() so the pickle and cPickle modules are more similar.Fred Drake2002-05-011-0/+3
|
* Implement an idea by Paul Rubin:Guido van Rossum2002-04-051-14/+12
| | | | | | | | Change pickling format for bools to use a backwards compatible encoding. This means you can pickle True or False on Python 2.3 and Python 2.2 or before will read it back as 1 or 0. The code used for pickling bools before would create pickles that could not be read in previous Python versions.
* Add the 'bool' type and its values 'False' and 'True', as described inGuido van Rossum2002-04-031-0/+18
| | | | | | | | | | | | | PEP 285. Everything described in the PEP is here, and there is even some documentation. I had to fix 12 unit tests; all but one of these were printing Boolean outcomes that changed from 0/1 to False/True. (The exception is test_unicode.py, which did a type(x) == type(y) style comparison. I could've fixed that with a single line using issubtype(x, type(y)), but instead chose to be explicit about those places where a bool is expected. Still to do: perhaps more documentation; change standard library modules to return False/True from predicates.
* Fix for SF 502085.Guido van Rossum2002-03-261-1/+5
| | | | | | Don't die when issubclass(t, TypeType) fails. Bugfix candidate (but I think it's too late for 2.2.1).
* SF #515018, delete global variable that was apparently used onlyNeal Norwitz2002-02-111-0/+1
| | | | in a list comprehension.
* Pickler.save(): Fix for SF bug #494904: Cannot pickle a class with aGuido van Rossum2001-12-191-0/+4
| | | | | | | | | | | metaclass, reported by Dan Parisien. Objects that are instances of custom metaclasses, i.e. whose class is a subclass of 'type', should be pickled the same as new-style classes (objects whose class is 'type'). This can't be done through a dispatch table entry, and the __reduce__ trick doesn't work for these, since it finds the unbound __reduce__ for instances of the class (inherited from 'object'). So check explicitly using issubclass().
* Two changes:Barry Warsaw2001-11-151-8/+6
| | | | | | | | | | | | | | load_inst(): Implement the security hook that cPickle already had. When unpickling callables which are not classes, we look to see if the object has an attribute __safe_for_unpickling__. If this exists and has a true value, then we can call it to create the unpickled object. Otherwise we raise an UnpicklingError. find_class(): We no longer mask ImportError, KeyError, and AttributeError by transforming them into SystemError. The latter is definitely not the right thing to do, so we let the former three exceptions simply propagate up if they occur, i.e. we remove the try/except!
* A better new, unique objectJeremy Hylton2001-11-091-1/+1
|
* Use cStringIO when available.Jeremy Hylton2001-10-151-36/+4
| | | | Remove test code. It's available in Lib/test/picklertester.py.
* Make these modules work when Python is compiled without Unicode support.Guido van Rossum2001-09-211-4/+10
|
* pickle.py, load_int(): Match cPickle's just-repaired ability to unpickleTim Peters2001-08-281-1/+5
| | | | | | | | 64-bit INTs on 32-bit boxes (where they become longs). Also exploit that int(str) and long(str) will ignore a trailing newline (saves creating a new string at the Python level). pickletester.py: Simulate reading a pickle produced by a 64-bit box.
* Address SF #451547. The approach is a bit draconian: any object thatGuido van Rossum2001-08-171-0/+14
| | | | | | | | | | 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.
* Merge of descr-branch back into trunk.Tim Peters2001-08-021-0/+1
|
* test_pickle works on sizeof(long)==8 boxes again.Tim Peters2001-04-101-11/+18
| | | | | | | | | | pickle.py The code implicitly assumed that all ints fit in 4 bytes, causing all sorts of mischief (from nonsense results to corrupted pickles). Repaired that. marshal.c The int marshaling code assumed that right shifts of signed longs sign-extend. Repaired that.
* Mechanical fiddling for easier reading: every "if" test was enclosed inTim Peters2001-04-101-35/+35
| | | | parens, but no "while" test. Removed the former.
* add module-level constants to __all__Skip Montanaro2001-02-181-0/+3
|
* Whitespace normalization.Tim Peters2001-02-091-2/+2
|
* a few more __all__ listsSkip Montanaro2001-02-071-0/+3
|
* Finn Bock (SF patch #103349):Guido van Rossum2001-01-221-0/+33
| | | | Allow pickle.py to be using with Jython unicode strings
* Whitespace normalization.Tim Peters2001-01-151-15/+15
|
* Minimal fix for the complaints about pickling Unicode objects. (SFGuido van Rossum2000-12-191-0/+2
| | | | | | | | | | | | | | bugs #126161 and 123634). The solution doesn't use the unicode-escape encoding; that has other problems (it seems not 100% reversible). Rather, it transforms the input Unicode object slightly before encoding it using raw-unicode-escape, so that the decoding will reconstruct the original string: backslash and newline characters are translated into their \uXXXX counterparts. This is backwards incompatible for strings containing backslashes, but for some of those strings, the pickling was already broken.
* Get rid of string module and string exceptions.Guido van Rossum2000-12-131-7/+10
|
* 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
|