[Python-checkins] r54139 - in python/trunk: Lib/test/test_descr.py Misc/NEWS Python/ceval.c
georg.brandl
python-checkins at python.org
Mon Mar 5 23:28:10 CET 2007
Author: georg.brandl
Date: Mon Mar 5 23:28:08 2007
New Revision: 54139
Modified:
python/trunk/Lib/test/test_descr.py
python/trunk/Misc/NEWS
python/trunk/Python/ceval.c
Log:
Patch #1674228: when assigning a slice (old-style), check for the
sq_ass_slice instead of the sq_slice slot.
Modified: python/trunk/Lib/test/test_descr.py
==============================================================================
--- python/trunk/Lib/test/test_descr.py (original)
+++ python/trunk/Lib/test/test_descr.py Mon Mar 5 23:28:08 2007
@@ -4206,6 +4206,19 @@
check(iexpr, c, N1)
check(iexpr, c, N2)
+def test_assign_slice():
+ # ceval.c's assign_slice used to check for
+ # tp->tp_as_sequence->sq_slice instead of
+ # tp->tp_as_sequence->sq_ass_slice
+
+ class C(object):
+ def __setslice__(self, start, stop, value):
+ self.value = value
+
+ c = C()
+ c[1:2] = 3
+ vereq(c.value, 3)
+
def test_main():
weakref_segfault() # Must be first, somehow
wrapper_segfault()
@@ -4301,6 +4314,7 @@
test_init()
methodwrapper()
notimplemented()
+ test_assign_slice()
from test import test_descr
run_doctest(test_descr, verbosity=True)
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Mon Mar 5 23:28:08 2007
@@ -12,6 +12,9 @@
Core and builtins
-----------------
+- Patch #1674228: when assigning a slice (old-style), check for the
+ sq_ass_slice instead of the sq_slice slot.
+
- When printing an unraisable error, don't print exceptions. before the name.
This duplicates the behavior whening normally printing exceptions.
Modified: python/trunk/Python/ceval.c
==============================================================================
--- python/trunk/Python/ceval.c (original)
+++ python/trunk/Python/ceval.c Mon Mar 5 23:28:08 2007
@@ -3927,7 +3927,7 @@
PyTypeObject *tp = u->ob_type;
PySequenceMethods *sq = tp->tp_as_sequence;
- if (sq && sq->sq_slice && ISINDEX(v) && ISINDEX(w)) {
+ if (sq && sq->sq_ass_slice && ISINDEX(v) && ISINDEX(w)) {
Py_ssize_t ilow = 0, ihigh = PY_SSIZE_T_MAX;
if (!_PyEval_SliceIndex(v, &ilow))
return -1;
More information about the Python-checkins
mailing list