[Python-checkins] r42478 - in python/branches/release24-maint: Doc/lib/libstdtypes.tex Python/ceval.c

georg.brandl python-checkins at python.org
Sun Feb 19 01:12:47 CET 2006


Author: georg.brandl
Date: Sun Feb 19 01:12:46 2006
New Revision: 42478

Modified:
   python/branches/release24-maint/Doc/lib/libstdtypes.tex
   python/branches/release24-maint/Python/ceval.c
Log:
Bug #801349: document that start/stop/step slice arguments can be None


Modified: python/branches/release24-maint/Doc/lib/libstdtypes.tex
==============================================================================
--- python/branches/release24-maint/Doc/lib/libstdtypes.tex	(original)
+++ python/branches/release24-maint/Doc/lib/libstdtypes.tex	Sun Feb 19 01:12:46 2006
@@ -532,9 +532,10 @@
 \item[(4)] The slice of \var{s} from \var{i} to \var{j} is defined as
   the sequence of items with index \var{k} such that \code{\var{i} <=
   \var{k} < \var{j}}.  If \var{i} or \var{j} is greater than
-  \code{len(\var{s})}, use \code{len(\var{s})}.  If \var{i} is omitted,
-  use \code{0}.  If \var{j} is omitted, use \code{len(\var{s})}.  If
-  \var{i} is greater than or equal to \var{j}, the slice is empty.
+  \code{len(\var{s})}, use \code{len(\var{s})}.  If \var{i} is omitted
+  or \code{None}, use \code{0}.  If \var{j} is omitted or \code{None},
+  use \code{len(\var{s})}.  If \var{i} is greater than or equal to \var{j},
+  the slice is empty.
 
 \item[(5)] The slice of \var{s} from \var{i} to \var{j} with step
   \var{k} is defined as the sequence of items with index 
@@ -543,9 +544,9 @@
   are \code{i}, \code{i+k}, \code{i+2*k}, \code{i+3*k} and so on, stopping when
   \var{j} is reached (but never including \var{j}).  If \var{i} or \var{j}
   is greater than \code{len(\var{s})}, use \code{len(\var{s})}.  If
-  \var{i} or \var{j} are omitted then they become ``end'' values
+  \var{i} or \var{j} are omitted or \code{None}, they become ``end'' values
   (which end depends on the sign of \var{k}).  Note, \var{k} cannot
-  be zero.
+  be zero. If \var{k} is \code{None}, it is treated like \code{1}.
 
 \item[(6)] If \var{s} and \var{t} are both strings, some Python
 implementations such as CPython can usually perform an in-place optimization

Modified: python/branches/release24-maint/Python/ceval.c
==============================================================================
--- python/branches/release24-maint/Python/ceval.c	(original)
+++ python/branches/release24-maint/Python/ceval.c	Sun Feb 19 01:12:46 2006
@@ -3894,7 +3894,7 @@
 			}
 		} else {
 			PyErr_SetString(PyExc_TypeError,
-					"slice indices must be integers");
+					"slice indices must be integers or None");
 			return 0;
 		}
 		/* Truncate -- very long indices are truncated anyway */


More information about the Python-checkins mailing list