Opened 2 years ago

# deepcopy() fails for lift_map from residue field of a number field

Reported by: Owned by: gh-walnutmonster major sage-9.8 number theory deepcopy, lift_map Peter Bruin, Michael Jung N/A

### Description

In sage 9.2 & 9.0 deepcopying the lift_map from a residue field at a prime does not finish because of recursion error

sage: R.<x> = ZZ[]
sage: f = x^2-2
sage: K.<a> = NumberField(f)
sage: P = K(2).factor()[0][0]
sage: F = K.residue_field(P)
sage: m = F.lift_map()
sage: deepcopy(m)

gives

---------------------------------------------------------------------------
RecursionError                            Traceback (most recent call last)
<ipython-input-26-c84bb92e2658> in <module>()
----> 1 deepcopy(m)

/home/sage/sage/local/lib/python3.7/copy.py in deepcopy(x, memo, _nil)
178                     y = x
179                 else:
--> 180                     y = _reconstruct(x, memo, *rv)
181
182     # If is its own copy, don't memoize.

/home/sage/sage/local/lib/python3.7/copy.py in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy)
272     if deep and args:
273         args = (deepcopy(arg, memo) for arg in args)
--> 274     y = func(*args)
275     if deep:
276         memo[id(x)] = y

/home/sage/sage/local/lib/python3.7/copy.py in <genexpr>(.0)
271     deep = memo is not None
272     if deep and args:
--> 273         args = (deepcopy(arg, memo) for arg in args)
274     y = func(*args)
275     if deep:

/home/sage/sage/local/lib/python3.7/copy.py in deepcopy(x, memo, _nil)
148     copier = _deepcopy_dispatch.get(cls)
149     if copier:
--> 150         y = copier(x, memo)
151     else:
152         try:

/home/sage/sage/local/lib/python3.7/copy.py in _deepcopy_dict(x, memo, deepcopy)
238     memo[id(x)] = y
239     for key, value in x.items():
--> 240         y[deepcopy(key, memo)] = deepcopy(value, memo)
241     return y
242 d[dict] = _deepcopy_dict

... last 5 frames repeated, from the frame below ...

/home/sage/sage/local/lib/python3.7/copy.py in deepcopy(x, memo, _nil)
178                     y = x
179                 else:
--> 180                     y = _reconstruct(x, memo, *rv)
181
182     # If is its own copy, don't memoize.

RecursionError: maximum recursion depth exceeded in comparison

and doing the following causes a segfault and crashes Sage

sage: sys.setrecursionlimit(2**30)
sage: deepcopy(m)
{{{

}}}

### comment:1 Changed 2 years ago by Matthias Köppe

I don't think the deepcopy protocol is implemented for Sage objects. Most Sage objects are immutable.

### comment:3 Changed 2 years ago by Matthias Köppe

Milestone: sage-9.2 → sage-9.3

### comment:4 Changed 20 months ago by Matthias Köppe

Milestone: sage-9.3 → sage-9.4

Moving this ticket to 9.4, as it seems unlikely that it will be merged in 9.3, which is in the release candidate stage

### comment:5 Changed 17 months ago by Matthias Köppe

Milestone: sage-9.4 → sage-9.5

### comment:6 follow-up:  7 Changed 15 months ago by Matthias Köppe

Dependencies: → #32478

This will be fixed in #32478

### comment:7 in reply to:  6 Changed 15 months ago by Matthias Köppe

Dependencies: #32478

This will be fixed in #32478

... actually no

### comment:8 Changed 12 months ago by Matthias Köppe

Milestone: sage-9.5 → sage-9.6

### comment:9 Changed 8 months ago by Matthias Köppe

Milestone: sage-9.6 → sage-9.7

### comment:10 Changed 3 months ago by Matthias Köppe

Milestone: sage-9.7 → sage-9.8
Note: See TracTickets for help on using tickets.