d = {}; d[0:1] = 1; d[0:1] = 2; print d[0:1]

Donn Cave donn at oz.net
Fri Mar 2 02:08:09 EST 2001


Quoth Robin Thomas <robin.thomas at starmedia.net>:
...
| PySequence_SetSlice, strangely, has a big chunk of code expressly written 
| to support slice assignment to mapping objects. From Objects/abstract.c 
| below. If we remove that code, we get the same effect.
...
|          /* the evil begins */
|          } else if ((mp = s->ob_type->tp_as_mapping) && mp->mp_ass_subscript) {
|                  int res;
|                  PyObject *slice = sliceobj_from_intint(i1, i2);
|                  if (!slice)
|                          return -1;
|                  res = mp->mp_ass_subscript(s, slice, o);
|                  Py_DECREF(slice);
|                  return res;
|          }
...
| Anybody have an explanation why this behavior was desired?

So far, I haven't seen any.  The class instance that is supposed
to benefit from all this already has tp_as_sequence, so it doesn't
reach that branch.

I think you ought to submit that as a patch, i.e., delete that
whole block.

	Donn Cave, donn at oz.net



More information about the Python-list mailing list