72 Commits

Author SHA1 Message Date
Martin Panter
ca56dd4767 Issue #28139: Fix messed up indentation
Also update the classmethod and staticmethod doc strings and comments to
match the RST documentation.
2016-09-17 07:54:55 +00:00
Chris Jerdonek
ad4b000179 Issue #14783: Backport changes from 3.2. 2012-10-07 20:37:54 -07:00
Mark Dickinson
218a8ab5eb Issues #16029, #16030: Fix pickling and repr of large xranges. 2012-09-28 20:36:36 +01:00
Antoine Pitrou
c83ea137d7 Untabify C files. Will watch buildbots. 2010-05-09 14:46:46 +00:00
Mark Dickinson
b2c3ca1e38 Silence MSVC warning about unary minus applied to unsigned type. 2009-11-16 17:33:25 +00:00
Mark Dickinson
009ae861f2 Avoid signed overflow in some xrange calculations, and extend
xrange tests to cover some special cases that caused problems
in py3k.  This is a partial backport of r76292-76293 (see
issue #7298.)
2009-11-15 12:31:13 +00:00
Alexandre Vassalotti
602d8db2bc Added better pickling support to xrange objects.
Cleaned up the unit test.
2008-06-10 04:01:23 +00:00
Alexandre Vassalotti
1f2f61a78f Issue 2582: Fix pickling of xrange objects. 2008-06-10 03:34:53 +00:00
Gregory P. Smith
dd96db63f6 This reverts r63675 based on the discussion in this thread:
http://mail.python.org/pipermail/python-dev/2008-June/079988.html

Python 2.6 should stick with PyString_* in its codebase.  The PyBytes_* names
in the spirit of 3.0 are available via a #define only.  See the email thread.
2008-06-09 04:58:54 +00:00
Christian Heimes
593daf545b Renamed PyString to PyBytes 2008-05-26 12:51:38 +00:00
Raymond Hettinger
0913166da2 Remove unnecessary modulo division.
The preceding test guarantees that 0 <= i < len.
2008-02-08 22:30:04 +00:00
Martin v. Löwis
72d206776d Remove "static forward" declaration. Move constructors
after the type objects.
2006-04-11 09:04:12 +00:00
Thomas Wouters
f4d8f39053 Make xrange more Py_ssize_t aware, by assuming a Py_ssize_t is always at
least as big as a long. I believe this to be a safe assumption that is being
made in many parts of CPython, but a check could be added.

len(xrange(sys.maxint)) works now, so fix the testsuite's odd exception for
64-bit platforms too. It also fixes 'zip(xrange(sys.maxint), it)' as a
portable-ish (if expensive) alternative to enumerate(it); since zip() now
calls len(), this was breaking on (real) 64-bit platforms. No additional
test was added for that behaviour.
2006-04-04 17:28:12 +00:00
Georg Brandl
347b30042b Remove unnecessary casts in type object initializers. 2006-03-30 11:57:00 +00:00
Martin v. Löwis
18e165558b Merge ssize_t branch. 2006-02-15 17:27:45 +00:00
Armin Rigo
f5b3e36493 Renamed _length_cue() to __length_hint__(). See:
http://mail.python.org/pipermail/python-dev/2006-February/060524.html
2006-02-11 21:32:43 +00:00
Raymond Hettinger
6b27cda643 Convert iterator __len__() methods to a private API. 2005-09-24 21:23:05 +00:00
Georg Brandl
02c42871cf Disallow keyword arguments for type constructors that don't use them.
(fixes bug #1119418)
2005-08-26 06:42:30 +00:00
Raymond Hettinger
665174834a Remove PyRange_New(). 2004-12-03 11:45:13 +00:00
Tim Peters
feec4533e2 Bug 1003935: xrange overflows
Added XXX comment about why the undocumented PyRange_New() API function
is too broken to be worth the considerable pain of repairing.

Changed range_new() to stop using PyRange_New().  This fixes a variety
of bogus errors.  Nothing in the core uses PyRange_New() now.

Documented that xrange() is intended to be simple and fast, and that
CPython restricts its arguments, and length of its result sequence, to
native C longs.

Added some tests that failed before the patch, and repaired a test that
relied on a bogus OverflowError getting raised.
2004-08-08 07:17:39 +00:00
Tim Peters
d976ab7caf Trimmed trailing whitespace. 2004-08-08 06:29:10 +00:00
Michael W. Hudson
f8df9a89bc Add a missing decref. 2004-08-02 13:22:01 +00:00
Raymond Hettinger
ef9bf4031a Tidied up the implementations of reversed (including the custom ones
for xrange and list objects).

* list.__reversed__ now checks the length of the sequence object before
  calling PyList_GET_ITEM() because the mutable could have changed length.

* all three implementations are now tranparent with respect to length and
  maintain the invariant len(it) == len(list(it)) even when the underlying
  sequence mutates.

* __builtin__.reversed() now frees the underlying sequence as soon
  as the iterator is exhausted.

* the code paths were rearranged so that the most common paths
  do not require a jump.
2004-03-10 10:10:42 +00:00
Raymond Hettinger
85c20a41df Implement and apply PEP 322, reverse iteration 2003-11-06 14:06:48 +00:00
Raymond Hettinger
1da1dbf458 Renamed PyObject_GenericGetIter to PyObject_SelfIter
to more accurately describe what the function does.

Suggested by Thomas Wouters.
2003-03-17 19:46:11 +00:00