Ticket #5769 (closed defect: invalid)

Opened 4 years ago

Last modified 3 years ago

power series are accidentally *mutable* (really dangerous)

Reported by: was Owned by: somebody
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: basic arithmetic Keywords:
Cc: Work issues:
Report Upstream: N/A Reviewers:
Authors: Merged in:
Dependencies: Stopgaps:

Description

wstein@sage:~/build/sage-3.4.1.rc2$ ./sage
----------------------------------------------------------------------
| Sage Version 3.4.1.rc2, Release Date: 2009-04-10                   |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
Loading Sage library. Current Mercurial branch is: ref2
sage: R.<t> = ZZ[[]]
sage: f = 1 + 17*t - 4*t^3 + O(t^5)
sage: f[1] = 10
...
IndexError: power series are immutable

Except they are mutable:

sage: f *= 2
sage: f
2 + 34*t - 8*t^3 + O(t^5)

But they shouldn't be! The _imul_ method needs to be deleted.

Change History

comment:1 Changed 3 years ago by lftabera

  • Status changed from new to closed
  • Resolution set to invalid
  • Report Upstream set to N/A

The code has nothing to do with mutability.

sage: a= (1,2,3)

a is a tuple, an immutable object

sage: a += a sage: a (1, 2, 3, 1, 2, 3)

sage: R.<t> = ZZ sage: f = 1 + 17*t - 4*t3 + O(t5) sage: g=f sage: g is f True sage: f+=f sage: f 2 + 34*t - 8*t3 + O(t5) sage: g 1 + 17*t - 4*t3 + O(t5) sage: f is g False

comment:2 Changed 3 years ago by mvngu

  • Milestone changed from sage-4.4.4 to sage-duplicate/invalid/wontfix
Note: See TracTickets for help on using tickets.