2
# The cycle GC collector can be executed when any GC-tracked object is
3
# allocated, e.g. during a call to PyList_New(), PyDict_New(), ...
4
# Moreover, it can invoke arbitrary Python code via a weakref callback.
5
# This means that there are many places in the source where an arbitrary
6
# mutation could unexpectedly occur.
8
# The example below shows list_slice() not expecting the call to
9
# PyList_New to mutate the input list. (Of course there are many
10
# more examples like this one.)
28
keepalive.append(weakref.ref(a, callback))
31
keepalive.append(lst[:])