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: |
Description
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.
Change History (4)
comment:1 Changed 6 years ago by
Branch: | → u/jdemeyer/fix_pickling_of_map |
---|
comment:2 Changed 6 years ago by
Commit: | → 2dcf3bbdd4712a7691b25e47e39384a198bb3b2d |
---|---|
Status: | new → needs_review |
comment:3 Changed 6 years ago by
Reviewers: | → Frédéric Chapoton |
---|---|
Status: | needs_review → positive_review |
ok, bot is green. Thanks a lot.
comment:4 Changed 5 years ago by
Branch: | u/jdemeyer/fix_pickling_of_map → 2dcf3bbdd4712a7691b25e47e39384a198bb3b2d |
---|---|
Resolution: | → fixed |
Status: | positive_review → closed |
Note: See
TracTickets for help on using
tickets.
New commits:
Use the correct parent when pickling a Map