Commit Graph

16 Commits

Author SHA1 Message Date
Tim Peters 2d62965734 cPickle can load pickles using proto 2 EXT[124] now, but can't yet
generate these opcodes.
2003-02-04 05:06:17 +00:00
Guido van Rossum d4b920c8bd Rename the extension registry variables to have leading underscores --
this clarifies that they are part of an internal API (albeit shared
between pickle.py, copy_reg.py and cPickle.c).

I'd like to do the same for copy_reg.dispatch_table, but worry that it
might be used by existing code.  This risk doesn't exist for the
extension registry.
2003-02-04 01:54:49 +00:00
Tim Peters 5b7da39f23 Brought some module variables into synch with pickle.py's current values.
Imported the extension-registry dicts from copy_reg.py, in preparation for
tackling EXT[124].
2003-02-04 00:21:07 +00:00
Tim Peters 1f1b2d2e68 Removed all uses of the out-of-favor __safe_for_unpickling__ magic
attr, and copy_reg.safe_constructors.
2003-02-01 02:16:37 +00:00
Guido van Rossum cf356fd865 Add extension management to __all__. 2003-01-31 20:34:07 +00:00
Guido van Rossum 255f3ee0a5 Support for extension codes. (By accident I checked in the tests first.) 2003-01-29 06:14:11 +00:00
Guido van Rossum 2a6f5b38ac _reduce(): Avoid infinite recursion in the pickler when self.__class__
doesn't have the _HEAPTYPE flag set, e.g. for time.struct_time and
posix.stat_result.

This fixes the immediate symptoms of SF bug #496873 (cPickle /
time.struct_time loop), replacing the infinite loop with an exception.
2001-12-27 16:27:28 +00:00
Guido van Rossum 00fb0c954f _reduce():
- Fix for SF bug #482752: __getstate__ & __setstate__ ignored (by Anon.)

    In fact, only __getstate__ isn't recognized.  This fixes that.

  - Separately, the test for base.__flags__ & _HEAPTYPE raised an
    AttributeError exception when a classic class was amongst the
    bases.  Fixed this with a hasattr() bandaid (classic classes never
    qualify as the "hard" base class anyway, which is what the code is
    trying to find).
2001-11-24 21:04:31 +00:00
Guido van Rossum 6cef6d5d62 Changes to copy() and deepcopy() in copy.py to support __reduce__ as a
fallback for objects that are neither supported by our dispatch table
nor have a __copy__ or __deepcopy__ method.

Changes to _reduce() in copy_reg.py to support reducing objects that
don't have a __dict__ -- copy.copy(complex()) now invokes _reduce().

Add tests for copy.copy() and copy.deepcopy() to test_regrtest.py.
2001-09-28 18:13:29 +00:00
Guido van Rossum 698acf98fd _reconstructor(): there's no need for tricks with assignment to
__class__.  The __new__ protocol is up to this.  (Thanks to Tim for
pointing this out.)
2001-09-25 19:46:05 +00:00
Guido van Rossum 3926a63d05 - Provisional support for pickling new-style objects. (*)
- Made cls.__module__ writable.

- Ensure that obj.__dict__ is returned as {}, not None, even upon first
  reference; it simply springs into life when you ask for it.

(*) The pickling support is provisional for the following reasons:

- It doesn't support classes with __slots__.

- It relies on additional support in copy_reg.py: the C method
  __reduce__, defined in the object class, really calls calling
  copy_reg._reduce(obj).  Eventually the Python code in copy_reg.py
  needs to be migrated to C, but I'd like to experiment with the
  Python implementation first.  The _reduce() code also relies on an
  additional helper function, _reconstructor(), defined in
  copy_reg.py; this should also be reimplemented in C.
2001-09-25 16:25:58 +00:00
Skip Montanaro e99d5ea25b added __all__ lists to a number of Python modules
added test script and expected output file as well
this closes patch 103297.
__all__ attributes will be added to other modules without first submitting
a patch, just adding the necessary line to the test script to verify
more-or-less correct implementation.
2001-01-20 19:54:20 +00:00
Fred Drake 78a6a36964 In the module docstring, clarify that this is used to register pickle
support for extension types, not classes.

pickle():  If the type is a class or if the reduction function is not
           callable, raise a TypeError.

constructor():  If the constructor is not callable, raise TypeError.

This (partially) closes SourceForge patch #101859.
2000-10-11 22:16:45 +00:00
Guido van Rossum 4acc25bd39 Mass patch by Ka-Ping Yee:
1. Comments at the beginning of the module, before
       functions, and before classes have been turned
       into docstrings.

    2. Tabs are normalized to four spaces.

Also, removed the "remove" function from dircmp.py, which reimplements
list.remove() (it must have been very old).
2000-02-02 15:10:15 +00:00
Guido van Rossum 72be30690f Added some minimal comments and tweaked lay-out a bit. 1997-05-20 18:03:22 +00:00
Guido van Rossum 47065620f2 support module for cPickle 1997-04-09 17:44:11 +00:00