A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2016-December/146911.html below:

[Python-Dev] List mutation in list_repr?

[Python-Dev] List mutation in list_repr? [Python-Dev] List mutation in list_repr?Hrvoje Niksic hrvoje.niksic at avl.com
Tue Dec 6 11:29:07 EST 2016
 > 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 passing `v->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.

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4