Opened 4 years ago
Closed 4 years ago
#23554 closed defect (fixed)
Fix pickling of Map
Reported by: | jdemeyer | 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 4 years ago by
- Branch set to u/jdemeyer/fix_pickling_of_map
comment:2 Changed 4 years ago by
- Commit set to 2dcf3bbdd4712a7691b25e47e39384a198bb3b2d
- Status changed from new to needs_review
comment:3 Changed 4 years ago by
- Reviewers set to Frédéric Chapoton
- Status changed from needs_review to positive_review
ok, bot is green. Thanks a lot.
comment:4 Changed 4 years ago by
- Branch changed from u/jdemeyer/fix_pickling_of_map to 2dcf3bbdd4712a7691b25e47e39384a198bb3b2d
- Resolution set to fixed
- Status changed from positive_review to closed
Note: See
TracTickets for help on using
tickets.
New commits:
Use the correct parent when pickling a Map