I reported this bug 1,5 years ago: https://groups.google.com/forum/#!topic/sage-devel/rvs5E6AEXVc
Not to point fingers, but you said: "The behavior is bad but I would not call it a bug. You modified wrongly the vector." ;-) Back then you proposed to change the semantics such that a vectors' parent is always the ambient space, i.e. V in your example. I would still say this is the best solution. Though David Roe disagreed on the follow-up post: https://groups.google.com/forum/#!topic/sage-devel/o9DNHs5zLLw On the first post, Volker suggested your solution 2. Best, Johan Vincent Delecroix writes: > Dear all, > > I went into the following bug: it is possible to modify an entry of > vector whose parent is a submodule of R^n. > > sage: V = VectorSpace(QQ, 3) > sage: M = V.subspace([(1,0,0,),(0,1,0)]) > sage: v = M() > sage: v > (0, 0, 0) > sage: v[2] = 2 # bug > sage: v > (0, 0, 2) > sage: v.parent() is M > True > > I opened https://trac.sagemath.org/ticket/22075 but I am not sure about > the solution. I see at least 2 > > 1) forbid __setitem__ > 2) check when a modification is done that the vector still belongs to > the given submodule (possibly together with a __enter__/__exit__ hook) > > Vincent -- -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.