[Python-Dev] List mutation in list_repr? (original) (raw)
Hrvoje Niksic hrvoje.niksic at avl.com
Tue Dec 6 11:29:07 EST 2016
- Previous message (by thread): [Python-Dev] List mutation in list_repr?
- Next message (by thread): [Python-Dev] List mutation in list_repr?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
and I also don’t see any clue in the source as to when [list mutation] would actually happen. Since inside the loop, the list object
v
is never accessed other than passingv->ob_item[i]
to the recursive repr call, there shouldn’t be any mutation on the list object itself.
The individual object can have a reference to the list and (in extreme cases) do with it what it pleases:
class Evil: def init(self, l): self.l = l
def __repr__(self):
del l[:]
return "evil"
l = [] l.append(Evil(l)) l.append(Evil(l)) print(l)
That is not something normal Python code does, but it shouldn't be allowed to crash the interpreter, either.
- Previous message (by thread): [Python-Dev] List mutation in list_repr?
- Next message (by thread): [Python-Dev] List mutation in list_repr?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]