Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pickling of Map #23554

Closed
jdemeyer opened this issue Jul 31, 2017 · 6 comments
Closed

Fix pickling of Map #23554

jdemeyer opened this issue Jul 31, 2017 · 6 comments

Comments

@jdemeyer
Copy link

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/forker.py", 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/forker.py", 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 sage.categories.map.unpickle_map (build/cythonized/sage/categories/map.c:2916)
        mor._set_parent(parent)
      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.

Component: pickling

Author: Jeroen Demeyer

Branch/Commit: 2dcf3bb

Reviewer: Frédéric Chapoton

Issue created by migration from https://trac.sagemath.org/ticket/23554

@jdemeyer jdemeyer added this to the sage-8.1 milestone Jul 31, 2017
@jdemeyer
Copy link
Author

Branch: u/jdemeyer/fix_pickling_of_map

@jdemeyer
Copy link
Author

New commits:

2dcf3bbUse the correct parent when pickling a Map

@jdemeyer
Copy link
Author

Commit: 2dcf3bb

@fchapoton
Copy link
Contributor

Reviewer: Frédéric Chapoton

@fchapoton
Copy link
Contributor

comment:3

ok, bot is green. Thanks a lot.

@vbraun
Copy link
Member

vbraun commented Aug 1, 2017

Changed branch from u/jdemeyer/fix_pickling_of_map to 2dcf3bb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants