add dedent() function, to remove indentation from multiline strings
(eg. triple-quoted strings). Differs from inspect.getdoc() by not
special-casing the first line (often a sensible approach for
non-docstring multiline strings). This should make this function more
general (symmetric 'indent' also possible), and more fitting for the
textwrap module.
Changed the example to show how to create types the new way:
- Use a class new method rather than a new function.
- Use self->ob_type->tp_free in deallocators
- Use attribute descriptors rather than set/getattr methods.
- Make the type usable as a base type.
I split the example into 3 parts:
1. The minimal new type
2. Adding attributes and methods.
3. Finer control over attributes.
It's much simpler to define builtin types. These updates hopefully
show this.
I also made minor wording changes in two other places.
I still need to update xxobject.c
Reverted a Py2.3b1 change to iterator in subclasses of list and tuple.
They had been changed to use __getitem__ whenever it had been overriden
in the subclass.
This caused some usabilty and performance problems. Also, it was
inconsistent with the rest of python where many container methods
access the underlying object directly without first checking for
an overridden getter. Users needing a change in iterator behavior
should override it directly.
* Increase dictionary growth rate resulting in more sparse dictionaries,
fewer lookup collisions, increased memory use, and better cache
performance. For dicts with over 50k entries, keep the current
growth rate in case an application is suffering from tight memory
constraints.
* Set the most common case (no resize) to fall-through the test.
Some version of gcc in the "RTEMS port running on the Coldfire (m5200)
processor" generates bad code for a loop in long_from_binary_base(),
comparing the wrong half of an int to a short. The patch changes the
decl of the short temp to be an int temp instead. This "simplifies"
the code enough that gcc no longer blows it.
('pgsql', '*', 252, []) and ('postgres', '*', 252, ['skip']),
but pwd.getgrgid(252) might return ('pgsql', '', 252, ['skip']).
Drop the test that tried to find a tuple similar to the one
returned from pwd.getgrgid() among those for the same gid returned
by pwd.getgrall(), as the only working definition of 'similar' seems
to be 'has the same gid'. This check can be done more directly.
This should fix SF bug #732783.
The latest changes to the redirect handler couldn't possibly have been
tested, because they did not compute a newurl and failed with a
NameError. The __name__ == "__main__": block has a test for
redirects.
Also, fix SF bug 723831. A urlopen() that failed because the host was
not found raised a socket.gaierror unlike earlier versions of
urllib2. The problem is that httplib actually establishes the
connection at a different point starting with Python 2.2. Move the
try/except to endheaders(), which is where the connection gets
established.