Commit Graph

9 Commits

Author SHA1 Message Date
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