A bug due to copying a cython object.

63 views
Skip to first unread message

Kwankyu Lee

unread,
May 17, 2019, 4:02:20 AM5/17/19
to sage-devel
Hi,

I observed

sage: F = GF(2)
sage: E = GF(4)
sage: phi = E.coerce_map_from(F); phi
Ring morphism:
  From: Finite Field of size 2
  To:   Finite Field in z2 of size 2^2
  Defn: 1 |--> 1
sage: phi.section()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
...
TypeError: 'NoneType' object is not callable

and on the other hand,

sage: psi = E._internal_coerce_map_from(F)
sage: psi.section()
Section of (map internal to coercion system -- copy before use)
Ring morphism:
  From: Finite Field of size 2
  To:   Finite Field in z2 of size 2^2

If you look into coerce_map_from() method, essentially phi = copy(psi), but while copying the cython object, the information about the section map of psi is lost, and thus the error above.

What is the proper way to copy a cython object with all its attributes?

Jeroen Demeyer

unread,
May 17, 2019, 6:03:13 AM5/17/19
to sage-...@googlegroups.com
On 2019-05-17 10:02, Kwankyu Lee wrote:
> What is the proper way to copy a cython object with all its attributes?

Write a __copy__ method doing the copy manually. Unless I'm missing a
Cython feature that helps with this.

Kwankyu Lee

unread,
May 17, 2019, 9:25:36 AM5/17/19
to sage-devel
This is now


which needs review.
Reply all
Reply to author
Forward
0 new messages