Ticket #10962 (needs_review defect)

Opened 2 years ago

Last modified 4 months ago

Set_PythonType objects are not picklable

Reported by: stumpc5 Owned by: was
Priority: major Milestone:
Component: pickling Keywords:
Cc: sage-combinat Work issues:
Report Upstream: N/A Reviewers:
Authors: Merged in:
Dependencies: Stopgaps:

Description (last modified by nthiery) (diff)

    sage: S = sage.structure.parent.Set_PythonType(tuple)
    sage: dumps(S)
    ------------------------------------------------------------
    Traceback (most recent call last):
      File "<ipython console>", line 1, in <module>
      File "sage_object.pyx", line 842, in sage.structure.sage_object.dumps (sage/structure/sage_object.c:8274)
      File "sage_object.pyx", line 217, in sage.structure.sage_object.SageObject.dumps (sage/structure/sage_object.c:2183)
    PicklingError: Can't pickle <type 'function'>: attribute lookup __builtin__.function failed

Attachments

trac_10962-pickle_set_pythontype.patch Download (1.5 KB) - added by vdelecroix 5 months ago.
trac_10962-pickle_set_pythontype.2.patch Download (5.7 KB) - added by vdelecroix 4 months ago.

Change History

comment:1 Changed 2 years ago by nthiery

  • Cc sage-combinat added
  • Owner changed from sage-combinat to was
  • Component changed from combinatorics to pickling
  • Description modified (diff)
  • Summary changed from Problem with pickle in CombinatorialFreeModule to Set_PythonType objects are not picklable

Changed 5 months ago by vdelecroix

comment:2 Changed 5 months ago by vdelecroix

I implement a __reduce__ method for Set_PythonType and now it works...

Best, Vincent

comment:3 Changed 4 months ago by vdelecroix

  • Status changed from new to needs_review

Changed 4 months ago by vdelecroix

comment:4 Changed 4 months ago by vdelecroix

I undo a change which produces error (because of some metaclass buisness). I also add a method is_finite in relation with the cardinality one.

apply only: trac_10962-pickle_set_pythontype.2.patch

comment:5 Changed 4 months ago by vdelecroix

Hi,

I added a relatively fast check at the very begining of the init method that verifies that the argument is a type or not (using the function PyType_Check from the C-API. It is the cause of many errors (see the log of the patchbot) and I do not know whether it is a good thing to check...

See the following  sage-devel thread.

Note: See TracTickets for help on using tickets.