1. 19 Dec, 2001 1 commit
    • Guido van Rossum's avatar
      Pickler.save(): Fix for SF bug #494904: Cannot pickle a class with a · cef0b49d
      Guido van Rossum authored
      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().
      cef0b49d
  2. 15 Nov, 2001 1 commit
    • Barry Warsaw's avatar
      Two changes: · 105008c9
      Barry Warsaw authored
      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!
      105008c9
  3. 09 Nov, 2001 1 commit
  4. 15 Oct, 2001 1 commit
  5. 21 Sep, 2001 1 commit
  6. 28 Aug, 2001 1 commit
  7. 17 Aug, 2001 1 commit
    • Guido van Rossum's avatar
      Address SF #451547. The approach is a bit draconian: any object that · 766d7cb0
      Guido van Rossum authored
      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.
      766d7cb0
  8. 02 Aug, 2001 1 commit
  9. 10 Apr, 2001 2 commits
  10. 18 Feb, 2001 1 commit
  11. 09 Feb, 2001 1 commit
  12. 07 Feb, 2001 1 commit
  13. 22 Jan, 2001 1 commit
  14. 15 Jan, 2001 1 commit
  15. 19 Dec, 2000 1 commit
    • Guido van Rossum's avatar
      Minimal fix for the complaints about pickling Unicode objects. (SF · dbcba5c5
      Guido van Rossum authored
      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.
      dbcba5c5
  16. 13 Dec, 2000 1 commit
  17. 15 Sep, 2000 1 commit
    • Jeremy Hylton's avatar
      Fix Bug #114293: · 5021c0f8
      Jeremy Hylton authored
          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
      5021c0f8
  18. 29 Jun, 2000 1 commit
  19. 10 Mar, 2000 1 commit
  20. 04 Feb, 2000 1 commit
    • Guido van Rossum's avatar
      More trivial comment -> docstring transformations by Ka-Ping Yee, · 0f5e51cb
      Guido van Rossum authored
      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.
      0f5e51cb
  21. 10 Oct, 1999 1 commit
    • Guido van Rossum's avatar
      Jeremy writes: · 29b9d983
      Guido van Rossum authored
      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).
      29b9d983
  22. 25 Mar, 1999 1 commit
  23. 22 Oct, 1998 1 commit
    • Guido van Rossum's avatar
      Jim Fulton writes: · c606e94a
      Guido van Rossum authored
      """
      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.
      """
      c606e94a
  24. 15 Sep, 1998 1 commit
  25. 27 May, 1998 1 commit
  26. 13 Apr, 1998 1 commit
  27. 31 Mar, 1998 2 commits
  28. 26 Mar, 1998 1 commit
  29. 13 Feb, 1998 1 commit
  30. 26 Jan, 1998 1 commit
    • Barry Warsaw's avatar
      Unpickler.load_inst(), Unpickler.load_obj(), Unpickler.load_build(): · 3cd30d4a
      Barry Warsaw authored
      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.
      3cd30d4a
  31. 10 Dec, 1997 2 commits
    • Guido van Rossum's avatar
      Jim Fulton writes: · f96c1896
      Guido van Rossum authored
      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.
      f96c1896
    • Guido van Rossum's avatar
      Don't specify base 0 to string.atoi when unpickling integers in text · f9f1761d
      Guido van Rossum authored
      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.)
      f9f1761d
  32. 05 Dec, 1997 1 commit
    • Guido van Rossum's avatar
      When instantiating a class with no arguments and where the class does · 6d19f23d
      Guido van Rossum authored
      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.
      6d19f23d
  33. 12 Sep, 1997 1 commit
    • Guido van Rossum's avatar
      Three independent changes: · cbb135e3
      Guido van Rossum authored
      - 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.
      cbb135e3
  34. 08 Sep, 1997 1 commit
    • Guido van Rossum's avatar
      *Semantic change*: when unpickling the instance variables of an · 64c14316
      Guido van Rossum authored
      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!
      64c14316
  35. 03 Sep, 1997 1 commit
  36. 25 Apr, 1997 1 commit
  37. 11 Apr, 1997 1 commit