Opened 6 years ago

Closed 5 years ago

#23554 closed defect (fixed)

Fix pickling of Map

Reported by: Jeroen Demeyer Owned by:
Priority: blocker Milestone: sage-8.1
Component: pickling Keywords:
Cc: Merged in:
Authors: Jeroen Demeyer Reviewers: Frédéric Chapoton
Report Upstream: N/A Work issues:
Branch: 2dcf3bb (Commits, GitHub, GitLab) Commit: 2dcf3bbdd4712a7691b25e47e39384a198bb3b2d
Dependencies: Stopgaps:

Status badges


Sometimes this happens:

sage -t src/sage/rings/fraction_field_FpT.pyx
File "src/sage/rings/fraction_field_FpT.pyx", line 1207, in sage.rings.fraction_field_FpT.FpT_Polyring_section
Failed example:
    fprime = loads(dumps(f))
Exception raised:
    Traceback (most recent call last):
      File "/usr/local/src/sage-config/local/lib/python2.7/site-packages/sage/doctest/", line 509, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/usr/local/src/sage-config/local/lib/python2.7/site-packages/sage/doctest/", line 872, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.rings.fraction_field_FpT.FpT_Polyring_section[4]>", line 1, in <module>
        fprime = loads(dumps(f))
      File "sage/structure/sage_object.pyx", line 1491, in sage.structure.sage_object.loads (build/cythonized/sage/structure/sage_object.c:16048)
        return unpickler.load()
      File "sage/categories/map.pyx", line 48, in (build/cythonized/sage/categories/map.c:2916)
      File "sage/structure/element.pyx", line 417, in sage.structure.element.Element._set_parent (build/cythonized/sage/structure/element.c:4223)
        self._parent = <Parent?>parent
    TypeError: ('Cannot convert NoneType to sage.structure.parent.Parent', <built-in function unpickle_map>, (<type 'sage.rings.fraction_field_FpT.Polyring_FpT_coerce'>
, None, {}, {'_is_coercion': True, '_domain': Univariate Polynomial Ring in t over Finite Field of size 5, '_repr_type_str': None, '_codomain': Fraction Field of Univar
iate Polynomial Ring in t over Finite Field of size 5, '_lift': None, 'p': 5}))

This is because Map computes the parent lazily: it can store self._parent = None. The actual parent is returned by the .parent() method, so we use that instead.

Change History (4)

comment:1 Changed 6 years ago by Jeroen Demeyer

Branch: u/jdemeyer/fix_pickling_of_map

comment:2 Changed 6 years ago by Jeroen Demeyer

Commit: 2dcf3bbdd4712a7691b25e47e39384a198bb3b2d
Status: newneeds_review

New commits:

2dcf3bbUse the correct parent when pickling a Map

comment:3 Changed 6 years ago by Frédéric Chapoton

Reviewers: Frédéric Chapoton
Status: needs_reviewpositive_review

ok, bot is green. Thanks a lot.

comment:4 Changed 5 years ago by Volker Braun

Branch: u/jdemeyer/fix_pickling_of_map2dcf3bbdd4712a7691b25e47e39384a198bb3b2d
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.