1991-02-19 12:39:46 +00:00
|
|
|
|
1990-10-14 12:07:46 +00:00
|
|
|
/* Tuple object implementation */
|
|
|
|
|
|
1997-05-02 03:12:38 +00:00
|
|
|
#include "Python.h"
|
2012-03-22 14:38:16 +01:00
|
|
|
#include "accu.h"
|
1990-10-14 12:07:46 +00:00
|
|
|
|
Patch by Charles G Waldman to avoid a sneaky memory leak in
_PyTuple_Resize(). In addition, a change suggested by Jeremy Hylton
to limit the size of the free lists is also merged into this patch.
Charles wrote initially:
"""
Test Case: run the following code:
class Nothing:
def __len__(self):
return 5
def __getitem__(self, i):
if i < 3:
return i
else:
raise IndexError, i
def g(a,*b,**c):
return
for x in xrange(1000000):
g(*Nothing())
and watch Python's memory use go up and up.
Diagnosis:
The analysis begins with the call to PySequence_Tuple at line 1641 in
ceval.c - the argument to g is seen to be a sequence but not a tuple,
so it needs to be converted from an abstract sequence to a concrete
tuple. PySequence_Tuple starts off by creating a new tuple of length
5 (line 1122 in abstract.c). Then at line 1149, since only 3 elements
were assigned, _PyTuple_Resize is called to make the 5-tuple into a
3-tuple. When we're all done the 3-tuple is decrefed, but rather than
being freed it is placed on the free_tuples cache.
The basic problem is that the 3-tuples are being added to the cache
but never picked up again, since _PyTuple_Resize doesn't make use of
the free_tuples cache. If you are resizing a 5-tuple to a 3-tuple and
there is already a 3-tuple in free_tuples[3], instead of using this
tuple, _PyTuple_Resize will realloc the 5-tuple to a 3-tuple. It
would more efficient to use the existing 3-tuple and cache the
5-tuple.
By making _PyTuple_Resize aware of the free_tuples (just as
PyTuple_New), we not only save a few calls to realloc, but also
prevent this misbehavior whereby tuples are being added to the
free_tuples list but never properly "recycled".
"""
And later:
"""
This patch replaces my submission of Sun, 16 Apr and addresses Jeremy
Hylton's suggestions that we also limit the size of the free tuple
list. I chose 2000 as the maximum number of tuples of any particular
size to save.
There was also a problem with the previous version of this patch
causing a core dump if Python was built with Py_TRACE_REFS. This is
fixed in the below version of the patch, which uses tupledealloc
instead of _Py_Dealloc.
"""
2000-04-21 21:15:05 +00:00
|
|
|
/* Speed optimization to avoid frequent malloc/free of small tuples */
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60568 | christian.heimes | 2008-02-04 19:48:38 +0100 (Mon, 04 Feb 2008) | 1 line
Increase debugging to investige failing tests on some build bots
........
r60570 | christian.heimes | 2008-02-04 20:30:05 +0100 (Mon, 04 Feb 2008) | 1 line
Small adjustments for test compact freelist test. It's no passing on Windows as well.
........
r60573 | amaury.forgeotdarc | 2008-02-04 21:53:14 +0100 (Mon, 04 Feb 2008) | 2 lines
Correct quotes in NEWS file
........
r60575 | amaury.forgeotdarc | 2008-02-04 22:45:05 +0100 (Mon, 04 Feb 2008) | 13 lines
#1750076: Debugger did not step on every iteration of a while statement.
The mapping between bytecode offsets and source lines (lnotab) did not contain
an entry for the beginning of the loop.
Now it does, and the lnotab can be a bit larger:
in particular, several statements on the same line generate several entries.
However, this does not bother the settrace function, which will trigger only
one 'line' event.
The lnotab seems to be exactly the same as with python2.4.
........
r60584 | amaury.forgeotdarc | 2008-02-05 01:26:21 +0100 (Tue, 05 Feb 2008) | 3 lines
Change r60575 broke test_compile:
there is no need to emit co_lnotab item when both offsets are zeros.
........
r60587 | skip.montanaro | 2008-02-05 03:32:16 +0100 (Tue, 05 Feb 2008) | 1 line
sync with most recent version from python-mode sf project
........
r60588 | lars.gustaebel | 2008-02-05 12:51:40 +0100 (Tue, 05 Feb 2008) | 5 lines
Issue #2004: Use mode 0700 for temporary directories and default
permissions for missing directories.
(will backport to 2.5)
........
r60590 | georg.brandl | 2008-02-05 13:01:24 +0100 (Tue, 05 Feb 2008) | 2 lines
Convert external links to internal links. Fixes #2010.
........
r60592 | marc-andre.lemburg | 2008-02-05 15:50:40 +0100 (Tue, 05 Feb 2008) | 3 lines
Keep distutils Python 2.1 compatible (or even Python 2.4 in this case).
........
r60593 | andrew.kuchling | 2008-02-05 17:06:57 +0100 (Tue, 05 Feb 2008) | 5 lines
Update PEP URL.
(This code is duplicated between pydoc and DocXMLRPCServer; maybe it
should be refactored as a GHOP project.)
2.5.2 backport candidate.
........
r60596 | guido.van.rossum | 2008-02-05 18:32:15 +0100 (Tue, 05 Feb 2008) | 2 lines
In the experimental 'Scanner' feature, the group count was set wrong.
........
r60602 | facundo.batista | 2008-02-05 20:03:32 +0100 (Tue, 05 Feb 2008) | 3 lines
Issue 1951. Converts wave test cases to unittest.
........
r60603 | georg.brandl | 2008-02-05 20:07:10 +0100 (Tue, 05 Feb 2008) | 2 lines
Actually run the test.
........
r60604 | skip.montanaro | 2008-02-05 20:24:30 +0100 (Tue, 05 Feb 2008) | 2 lines
correct object name
........
r60605 | georg.brandl | 2008-02-05 20:58:17 +0100 (Tue, 05 Feb 2008) | 7 lines
* Use the same code to profile for test_profile and test_cprofile.
* Convert both to unittest.
* Use the same unit testing code.
* Include the expected output in both test files.
* Make it possible to regenerate the expected output by running
the file as a script with an '-r' argument.
........
r60613 | raymond.hettinger | 2008-02-06 02:49:00 +0100 (Wed, 06 Feb 2008) | 1 line
Sync-up with Py3k work.
........
r60614 | christian.heimes | 2008-02-06 13:44:34 +0100 (Wed, 06 Feb 2008) | 1 line
Limit free list of method and builtin function objects to 256 entries each.
........
r60616 | christian.heimes | 2008-02-06 14:33:44 +0100 (Wed, 06 Feb 2008) | 7 lines
Unified naming convention for free lists and their limits. All free lists
in Object/ are named ``free_list``, the counter ``numfree`` and the upper
limit is a macro ``PyName_MAXFREELIST`` inside an #ifndef block.
The chances should make it easier to adjust Python for platforms with
less memory, e.g. mobile phones.
........
2008-02-06 14:31:34 +00:00
|
|
|
#ifndef PyTuple_MAXSAVESIZE
|
2010-05-09 15:52:27 +00:00
|
|
|
#define PyTuple_MAXSAVESIZE 20 /* Largest tuple to save on free list */
|
Patch by Charles G Waldman to avoid a sneaky memory leak in
_PyTuple_Resize(). In addition, a change suggested by Jeremy Hylton
to limit the size of the free lists is also merged into this patch.
Charles wrote initially:
"""
Test Case: run the following code:
class Nothing:
def __len__(self):
return 5
def __getitem__(self, i):
if i < 3:
return i
else:
raise IndexError, i
def g(a,*b,**c):
return
for x in xrange(1000000):
g(*Nothing())
and watch Python's memory use go up and up.
Diagnosis:
The analysis begins with the call to PySequence_Tuple at line 1641 in
ceval.c - the argument to g is seen to be a sequence but not a tuple,
so it needs to be converted from an abstract sequence to a concrete
tuple. PySequence_Tuple starts off by creating a new tuple of length
5 (line 1122 in abstract.c). Then at line 1149, since only 3 elements
were assigned, _PyTuple_Resize is called to make the 5-tuple into a
3-tuple. When we're all done the 3-tuple is decrefed, but rather than
being freed it is placed on the free_tuples cache.
The basic problem is that the 3-tuples are being added to the cache
but never picked up again, since _PyTuple_Resize doesn't make use of
the free_tuples cache. If you are resizing a 5-tuple to a 3-tuple and
there is already a 3-tuple in free_tuples[3], instead of using this
tuple, _PyTuple_Resize will realloc the 5-tuple to a 3-tuple. It
would more efficient to use the existing 3-tuple and cache the
5-tuple.
By making _PyTuple_Resize aware of the free_tuples (just as
PyTuple_New), we not only save a few calls to realloc, but also
prevent this misbehavior whereby tuples are being added to the
free_tuples list but never properly "recycled".
"""
And later:
"""
This patch replaces my submission of Sun, 16 Apr and addresses Jeremy
Hylton's suggestions that we also limit the size of the free tuple
list. I chose 2000 as the maximum number of tuples of any particular
size to save.
There was also a problem with the previous version of this patch
causing a core dump if Python was built with Py_TRACE_REFS. This is
fixed in the below version of the patch, which uses tupledealloc
instead of _Py_Dealloc.
"""
2000-04-21 21:15:05 +00:00
|
|
|
#endif
|
2010-05-09 15:52:27 +00:00
|
|
|
#ifndef PyTuple_MAXFREELIST
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60568 | christian.heimes | 2008-02-04 19:48:38 +0100 (Mon, 04 Feb 2008) | 1 line
Increase debugging to investige failing tests on some build bots
........
r60570 | christian.heimes | 2008-02-04 20:30:05 +0100 (Mon, 04 Feb 2008) | 1 line
Small adjustments for test compact freelist test. It's no passing on Windows as well.
........
r60573 | amaury.forgeotdarc | 2008-02-04 21:53:14 +0100 (Mon, 04 Feb 2008) | 2 lines
Correct quotes in NEWS file
........
r60575 | amaury.forgeotdarc | 2008-02-04 22:45:05 +0100 (Mon, 04 Feb 2008) | 13 lines
#1750076: Debugger did not step on every iteration of a while statement.
The mapping between bytecode offsets and source lines (lnotab) did not contain
an entry for the beginning of the loop.
Now it does, and the lnotab can be a bit larger:
in particular, several statements on the same line generate several entries.
However, this does not bother the settrace function, which will trigger only
one 'line' event.
The lnotab seems to be exactly the same as with python2.4.
........
r60584 | amaury.forgeotdarc | 2008-02-05 01:26:21 +0100 (Tue, 05 Feb 2008) | 3 lines
Change r60575 broke test_compile:
there is no need to emit co_lnotab item when both offsets are zeros.
........
r60587 | skip.montanaro | 2008-02-05 03:32:16 +0100 (Tue, 05 Feb 2008) | 1 line
sync with most recent version from python-mode sf project
........
r60588 | lars.gustaebel | 2008-02-05 12:51:40 +0100 (Tue, 05 Feb 2008) | 5 lines
Issue #2004: Use mode 0700 for temporary directories and default
permissions for missing directories.
(will backport to 2.5)
........
r60590 | georg.brandl | 2008-02-05 13:01:24 +0100 (Tue, 05 Feb 2008) | 2 lines
Convert external links to internal links. Fixes #2010.
........
r60592 | marc-andre.lemburg | 2008-02-05 15:50:40 +0100 (Tue, 05 Feb 2008) | 3 lines
Keep distutils Python 2.1 compatible (or even Python 2.4 in this case).
........
r60593 | andrew.kuchling | 2008-02-05 17:06:57 +0100 (Tue, 05 Feb 2008) | 5 lines
Update PEP URL.
(This code is duplicated between pydoc and DocXMLRPCServer; maybe it
should be refactored as a GHOP project.)
2.5.2 backport candidate.
........
r60596 | guido.van.rossum | 2008-02-05 18:32:15 +0100 (Tue, 05 Feb 2008) | 2 lines
In the experimental 'Scanner' feature, the group count was set wrong.
........
r60602 | facundo.batista | 2008-02-05 20:03:32 +0100 (Tue, 05 Feb 2008) | 3 lines
Issue 1951. Converts wave test cases to unittest.
........
r60603 | georg.brandl | 2008-02-05 20:07:10 +0100 (Tue, 05 Feb 2008) | 2 lines
Actually run the test.
........
r60604 | skip.montanaro | 2008-02-05 20:24:30 +0100 (Tue, 05 Feb 2008) | 2 lines
correct object name
........
r60605 | georg.brandl | 2008-02-05 20:58:17 +0100 (Tue, 05 Feb 2008) | 7 lines
* Use the same code to profile for test_profile and test_cprofile.
* Convert both to unittest.
* Use the same unit testing code.
* Include the expected output in both test files.
* Make it possible to regenerate the expected output by running
the file as a script with an '-r' argument.
........
r60613 | raymond.hettinger | 2008-02-06 02:49:00 +0100 (Wed, 06 Feb 2008) | 1 line
Sync-up with Py3k work.
........
r60614 | christian.heimes | 2008-02-06 13:44:34 +0100 (Wed, 06 Feb 2008) | 1 line
Limit free list of method and builtin function objects to 256 entries each.
........
r60616 | christian.heimes | 2008-02-06 14:33:44 +0100 (Wed, 06 Feb 2008) | 7 lines
Unified naming convention for free lists and their limits. All free lists
in Object/ are named ``free_list``, the counter ``numfree`` and the upper
limit is a macro ``PyName_MAXFREELIST`` inside an #ifndef block.
The chances should make it easier to adjust Python for platforms with
less memory, e.g. mobile phones.
........
2008-02-06 14:31:34 +00:00
|
|
|
#define PyTuple_MAXFREELIST 2000 /* Maximum number of tuples of each size to save */
|
1993-10-15 16:18:48 +00:00
|
|
|
#endif
|
|
|
|
|
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60568 | christian.heimes | 2008-02-04 19:48:38 +0100 (Mon, 04 Feb 2008) | 1 line
Increase debugging to investige failing tests on some build bots
........
r60570 | christian.heimes | 2008-02-04 20:30:05 +0100 (Mon, 04 Feb 2008) | 1 line
Small adjustments for test compact freelist test. It's no passing on Windows as well.
........
r60573 | amaury.forgeotdarc | 2008-02-04 21:53:14 +0100 (Mon, 04 Feb 2008) | 2 lines
Correct quotes in NEWS file
........
r60575 | amaury.forgeotdarc | 2008-02-04 22:45:05 +0100 (Mon, 04 Feb 2008) | 13 lines
#1750076: Debugger did not step on every iteration of a while statement.
The mapping between bytecode offsets and source lines (lnotab) did not contain
an entry for the beginning of the loop.
Now it does, and the lnotab can be a bit larger:
in particular, several statements on the same line generate several entries.
However, this does not bother the settrace function, which will trigger only
one 'line' event.
The lnotab seems to be exactly the same as with python2.4.
........
r60584 | amaury.forgeotdarc | 2008-02-05 01:26:21 +0100 (Tue, 05 Feb 2008) | 3 lines
Change r60575 broke test_compile:
there is no need to emit co_lnotab item when both offsets are zeros.
........
r60587 | skip.montanaro | 2008-02-05 03:32:16 +0100 (Tue, 05 Feb 2008) | 1 line
sync with most recent version from python-mode sf project
........
r60588 | lars.gustaebel | 2008-02-05 12:51:40 +0100 (Tue, 05 Feb 2008) | 5 lines
Issue #2004: Use mode 0700 for temporary directories and default
permissions for missing directories.
(will backport to 2.5)
........
r60590 | georg.brandl | 2008-02-05 13:01:24 +0100 (Tue, 05 Feb 2008) | 2 lines
Convert external links to internal links. Fixes #2010.
........
r60592 | marc-andre.lemburg | 2008-02-05 15:50:40 +0100 (Tue, 05 Feb 2008) | 3 lines
Keep distutils Python 2.1 compatible (or even Python 2.4 in this case).
........
r60593 | andrew.kuchling | 2008-02-05 17:06:57 +0100 (Tue, 05 Feb 2008) | 5 lines
Update PEP URL.
(This code is duplicated between pydoc and DocXMLRPCServer; maybe it
should be refactored as a GHOP project.)
2.5.2 backport candidate.
........
r60596 | guido.van.rossum | 2008-02-05 18:32:15 +0100 (Tue, 05 Feb 2008) | 2 lines
In the experimental 'Scanner' feature, the group count was set wrong.
........
r60602 | facundo.batista | 2008-02-05 20:03:32 +0100 (Tue, 05 Feb 2008) | 3 lines
Issue 1951. Converts wave test cases to unittest.
........
r60603 | georg.brandl | 2008-02-05 20:07:10 +0100 (Tue, 05 Feb 2008) | 2 lines
Actually run the test.
........
r60604 | skip.montanaro | 2008-02-05 20:24:30 +0100 (Tue, 05 Feb 2008) | 2 lines
correct object name
........
r60605 | georg.brandl | 2008-02-05 20:58:17 +0100 (Tue, 05 Feb 2008) | 7 lines
* Use the same code to profile for test_profile and test_cprofile.
* Convert both to unittest.
* Use the same unit testing code.
* Include the expected output in both test files.
* Make it possible to regenerate the expected output by running
the file as a script with an '-r' argument.
........
r60613 | raymond.hettinger | 2008-02-06 02:49:00 +0100 (Wed, 06 Feb 2008) | 1 line
Sync-up with Py3k work.
........
r60614 | christian.heimes | 2008-02-06 13:44:34 +0100 (Wed, 06 Feb 2008) | 1 line
Limit free list of method and builtin function objects to 256 entries each.
........
r60616 | christian.heimes | 2008-02-06 14:33:44 +0100 (Wed, 06 Feb 2008) | 7 lines
Unified naming convention for free lists and their limits. All free lists
in Object/ are named ``free_list``, the counter ``numfree`` and the upper
limit is a macro ``PyName_MAXFREELIST`` inside an #ifndef block.
The chances should make it easier to adjust Python for platforms with
less memory, e.g. mobile phones.
........
2008-02-06 14:31:34 +00:00
|
|
|
#if PyTuple_MAXSAVESIZE > 0
|
|
|
|
|
/* Entries 1 up to PyTuple_MAXSAVESIZE are free lists, entry 0 is the empty
|
1993-10-15 16:18:48 +00:00
|
|
|
tuple () of which at most one instance will be allocated.
|
|
|
|
|
*/
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60568 | christian.heimes | 2008-02-04 19:48:38 +0100 (Mon, 04 Feb 2008) | 1 line
Increase debugging to investige failing tests on some build bots
........
r60570 | christian.heimes | 2008-02-04 20:30:05 +0100 (Mon, 04 Feb 2008) | 1 line
Small adjustments for test compact freelist test. It's no passing on Windows as well.
........
r60573 | amaury.forgeotdarc | 2008-02-04 21:53:14 +0100 (Mon, 04 Feb 2008) | 2 lines
Correct quotes in NEWS file
........
r60575 | amaury.forgeotdarc | 2008-02-04 22:45:05 +0100 (Mon, 04 Feb 2008) | 13 lines
#1750076: Debugger did not step on every iteration of a while statement.
The mapping between bytecode offsets and source lines (lnotab) did not contain
an entry for the beginning of the loop.
Now it does, and the lnotab can be a bit larger:
in particular, several statements on the same line generate several entries.
However, this does not bother the settrace function, which will trigger only
one 'line' event.
The lnotab seems to be exactly the same as with python2.4.
........
r60584 | amaury.forgeotdarc | 2008-02-05 01:26:21 +0100 (Tue, 05 Feb 2008) | 3 lines
Change r60575 broke test_compile:
there is no need to emit co_lnotab item when both offsets are zeros.
........
r60587 | skip.montanaro | 2008-02-05 03:32:16 +0100 (Tue, 05 Feb 2008) | 1 line
sync with most recent version from python-mode sf project
........
r60588 | lars.gustaebel | 2008-02-05 12:51:40 +0100 (Tue, 05 Feb 2008) | 5 lines
Issue #2004: Use mode 0700 for temporary directories and default
permissions for missing directories.
(will backport to 2.5)
........
r60590 | georg.brandl | 2008-02-05 13:01:24 +0100 (Tue, 05 Feb 2008) | 2 lines
Convert external links to internal links. Fixes #2010.
........
r60592 | marc-andre.lemburg | 2008-02-05 15:50:40 +0100 (Tue, 05 Feb 2008) | 3 lines
Keep distutils Python 2.1 compatible (or even Python 2.4 in this case).
........
r60593 | andrew.kuchling | 2008-02-05 17:06:57 +0100 (Tue, 05 Feb 2008) | 5 lines
Update PEP URL.
(This code is duplicated between pydoc and DocXMLRPCServer; maybe it
should be refactored as a GHOP project.)
2.5.2 backport candidate.
........
r60596 | guido.van.rossum | 2008-02-05 18:32:15 +0100 (Tue, 05 Feb 2008) | 2 lines
In the experimental 'Scanner' feature, the group count was set wrong.
........
r60602 | facundo.batista | 2008-02-05 20:03:32 +0100 (Tue, 05 Feb 2008) | 3 lines
Issue 1951. Converts wave test cases to unittest.
........
r60603 | georg.brandl | 2008-02-05 20:07:10 +0100 (Tue, 05 Feb 2008) | 2 lines
Actually run the test.
........
r60604 | skip.montanaro | 2008-02-05 20:24:30 +0100 (Tue, 05 Feb 2008) | 2 lines
correct object name
........
r60605 | georg.brandl | 2008-02-05 20:58:17 +0100 (Tue, 05 Feb 2008) | 7 lines
* Use the same code to profile for test_profile and test_cprofile.
* Convert both to unittest.
* Use the same unit testing code.
* Include the expected output in both test files.
* Make it possible to regenerate the expected output by running
the file as a script with an '-r' argument.
........
r60613 | raymond.hettinger | 2008-02-06 02:49:00 +0100 (Wed, 06 Feb 2008) | 1 line
Sync-up with Py3k work.
........
r60614 | christian.heimes | 2008-02-06 13:44:34 +0100 (Wed, 06 Feb 2008) | 1 line
Limit free list of method and builtin function objects to 256 entries each.
........
r60616 | christian.heimes | 2008-02-06 14:33:44 +0100 (Wed, 06 Feb 2008) | 7 lines
Unified naming convention for free lists and their limits. All free lists
in Object/ are named ``free_list``, the counter ``numfree`` and the upper
limit is a macro ``PyName_MAXFREELIST`` inside an #ifndef block.
The chances should make it easier to adjust Python for platforms with
less memory, e.g. mobile phones.
........
2008-02-06 14:31:34 +00:00
|
|
|
static PyTupleObject *free_list[PyTuple_MAXSAVESIZE];
|
|
|
|
|
static int numfree[PyTuple_MAXSAVESIZE];
|
1993-10-15 16:18:48 +00:00
|
|
|
#endif
|
|
|
|
|
#ifdef COUNT_ALLOCS
|
2009-01-11 17:13:55 +00:00
|
|
|
Py_ssize_t fast_tuple_allocs;
|
|
|
|
|
Py_ssize_t tuple_zero_allocs;
|
1993-10-15 16:18:48 +00:00
|
|
|
#endif
|
|
|
|
|
|
2009-03-23 18:52:06 +00:00
|
|
|
/* Debug statistic to count GC tracking of tuples.
|
|
|
|
|
Please note that tuples are only untracked when considered by the GC, and
|
|
|
|
|
many of them will be dead before. Therefore, a tracking rate close to 100%
|
|
|
|
|
does not necessarily prove that the heuristic is inefficient.
|
|
|
|
|
*/
|
|
|
|
|
#ifdef SHOW_TRACK_COUNT
|
|
|
|
|
static Py_ssize_t count_untracked = 0;
|
|
|
|
|
static Py_ssize_t count_tracked = 0;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
show_track(void)
|
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
fprintf(stderr, "Tuples created: %" PY_FORMAT_SIZE_T "d\n",
|
|
|
|
|
count_tracked + count_untracked);
|
|
|
|
|
fprintf(stderr, "Tuples tracked by the GC: %" PY_FORMAT_SIZE_T
|
|
|
|
|
"d\n", count_tracked);
|
|
|
|
|
fprintf(stderr, "%.2f%% tuple tracking rate\n\n",
|
|
|
|
|
(100.0*count_tracked/(count_untracked+count_tracked)));
|
2009-03-23 18:52:06 +00:00
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-06-22 14:55:41 -04:00
|
|
|
/* Print summary info about the state of the optimized allocator */
|
|
|
|
|
void
|
|
|
|
|
_PyTuple_DebugMallocStats(FILE *out)
|
|
|
|
|
{
|
|
|
|
|
#if PyTuple_MAXSAVESIZE > 0
|
|
|
|
|
int i;
|
|
|
|
|
char buf[128];
|
|
|
|
|
for (i = 1; i < PyTuple_MAXSAVESIZE; i++) {
|
|
|
|
|
PyOS_snprintf(buf, sizeof(buf),
|
|
|
|
|
"free %d-sized PyTupleObject", i);
|
|
|
|
|
_PyDebugAllocatorStats(out,
|
|
|
|
|
buf,
|
|
|
|
|
numfree[i], _PyObject_VAR_SIZE(&PyTuple_Type, i));
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2009-03-23 18:52:06 +00:00
|
|
|
|
1997-05-02 03:12:38 +00:00
|
|
|
PyObject *
|
2006-02-15 17:27:45 +00:00
|
|
|
PyTuple_New(register Py_ssize_t size)
|
1990-10-14 12:07:46 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
register PyTupleObject *op;
|
|
|
|
|
Py_ssize_t i;
|
|
|
|
|
if (size < 0) {
|
|
|
|
|
PyErr_BadInternalCall();
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60568 | christian.heimes | 2008-02-04 19:48:38 +0100 (Mon, 04 Feb 2008) | 1 line
Increase debugging to investige failing tests on some build bots
........
r60570 | christian.heimes | 2008-02-04 20:30:05 +0100 (Mon, 04 Feb 2008) | 1 line
Small adjustments for test compact freelist test. It's no passing on Windows as well.
........
r60573 | amaury.forgeotdarc | 2008-02-04 21:53:14 +0100 (Mon, 04 Feb 2008) | 2 lines
Correct quotes in NEWS file
........
r60575 | amaury.forgeotdarc | 2008-02-04 22:45:05 +0100 (Mon, 04 Feb 2008) | 13 lines
#1750076: Debugger did not step on every iteration of a while statement.
The mapping between bytecode offsets and source lines (lnotab) did not contain
an entry for the beginning of the loop.
Now it does, and the lnotab can be a bit larger:
in particular, several statements on the same line generate several entries.
However, this does not bother the settrace function, which will trigger only
one 'line' event.
The lnotab seems to be exactly the same as with python2.4.
........
r60584 | amaury.forgeotdarc | 2008-02-05 01:26:21 +0100 (Tue, 05 Feb 2008) | 3 lines
Change r60575 broke test_compile:
there is no need to emit co_lnotab item when both offsets are zeros.
........
r60587 | skip.montanaro | 2008-02-05 03:32:16 +0100 (Tue, 05 Feb 2008) | 1 line
sync with most recent version from python-mode sf project
........
r60588 | lars.gustaebel | 2008-02-05 12:51:40 +0100 (Tue, 05 Feb 2008) | 5 lines
Issue #2004: Use mode 0700 for temporary directories and default
permissions for missing directories.
(will backport to 2.5)
........
r60590 | georg.brandl | 2008-02-05 13:01:24 +0100 (Tue, 05 Feb 2008) | 2 lines
Convert external links to internal links. Fixes #2010.
........
r60592 | marc-andre.lemburg | 2008-02-05 15:50:40 +0100 (Tue, 05 Feb 2008) | 3 lines
Keep distutils Python 2.1 compatible (or even Python 2.4 in this case).
........
r60593 | andrew.kuchling | 2008-02-05 17:06:57 +0100 (Tue, 05 Feb 2008) | 5 lines
Update PEP URL.
(This code is duplicated between pydoc and DocXMLRPCServer; maybe it
should be refactored as a GHOP project.)
2.5.2 backport candidate.
........
r60596 | guido.van.rossum | 2008-02-05 18:32:15 +0100 (Tue, 05 Feb 2008) | 2 lines
In the experimental 'Scanner' feature, the group count was set wrong.
........
r60602 | facundo.batista | 2008-02-05 20:03:32 +0100 (Tue, 05 Feb 2008) | 3 lines
Issue 1951. Converts wave test cases to unittest.
........
r60603 | georg.brandl | 2008-02-05 20:07:10 +0100 (Tue, 05 Feb 2008) | 2 lines
Actually run the test.
........
r60604 | skip.montanaro | 2008-02-05 20:24:30 +0100 (Tue, 05 Feb 2008) | 2 lines
correct object name
........
r60605 | georg.brandl | 2008-02-05 20:58:17 +0100 (Tue, 05 Feb 2008) | 7 lines
* Use the same code to profile for test_profile and test_cprofile.
* Convert both to unittest.
* Use the same unit testing code.
* Include the expected output in both test files.
* Make it possible to regenerate the expected output by running
the file as a script with an '-r' argument.
........
r60613 | raymond.hettinger | 2008-02-06 02:49:00 +0100 (Wed, 06 Feb 2008) | 1 line
Sync-up with Py3k work.
........
r60614 | christian.heimes | 2008-02-06 13:44:34 +0100 (Wed, 06 Feb 2008) | 1 line
Limit free list of method and builtin function objects to 256 entries each.
........
r60616 | christian.heimes | 2008-02-06 14:33:44 +0100 (Wed, 06 Feb 2008) | 7 lines
Unified naming convention for free lists and their limits. All free lists
in Object/ are named ``free_list``, the counter ``numfree`` and the upper
limit is a macro ``PyName_MAXFREELIST`` inside an #ifndef block.
The chances should make it easier to adjust Python for platforms with
less memory, e.g. mobile phones.
........
2008-02-06 14:31:34 +00:00
|
|
|
#if PyTuple_MAXSAVESIZE > 0
|
2010-05-09 15:52:27 +00:00
|
|
|
if (size == 0 && free_list[0]) {
|
|
|
|
|
op = free_list[0];
|
|
|
|
|
Py_INCREF(op);
|
1993-10-15 16:18:48 +00:00
|
|
|
#ifdef COUNT_ALLOCS
|
2010-05-09 15:52:27 +00:00
|
|
|
tuple_zero_allocs++;
|
1993-10-15 16:18:48 +00:00
|
|
|
#endif
|
2010-05-09 15:52:27 +00:00
|
|
|
return (PyObject *) op;
|
|
|
|
|
}
|
|
|
|
|
if (size < PyTuple_MAXSAVESIZE && (op = free_list[size]) != NULL) {
|
|
|
|
|
free_list[size] = (PyTupleObject *) op->ob_item[0];
|
|
|
|
|
numfree[size]--;
|
1993-10-15 16:18:48 +00:00
|
|
|
#ifdef COUNT_ALLOCS
|
2010-05-09 15:52:27 +00:00
|
|
|
fast_tuple_allocs++;
|
1998-12-11 14:56:38 +00:00
|
|
|
#endif
|
2010-05-09 15:52:27 +00:00
|
|
|
/* Inline PyObject_InitVar */
|
1998-12-11 14:56:38 +00:00
|
|
|
#ifdef Py_TRACE_REFS
|
2010-05-09 15:52:27 +00:00
|
|
|
Py_SIZE(op) = size;
|
|
|
|
|
Py_TYPE(op) = &PyTuple_Type;
|
1993-10-15 16:18:48 +00:00
|
|
|
#endif
|
2010-05-09 15:52:27 +00:00
|
|
|
_Py_NewReference((PyObject *)op);
|
|
|
|
|
}
|
|
|
|
|
else
|
1993-10-15 16:18:48 +00:00
|
|
|
#endif
|
2010-05-09 15:52:27 +00:00
|
|
|
{
|
|
|
|
|
/* Check for overflow */
|
2012-10-06 18:04:49 +01:00
|
|
|
if (size > (PY_SSIZE_T_MAX - sizeof(PyTupleObject) -
|
|
|
|
|
sizeof(PyObject *)) / sizeof(PyObject *)) {
|
2010-05-09 15:52:27 +00:00
|
|
|
return PyErr_NoMemory();
|
|
|
|
|
}
|
|
|
|
|
op = PyObject_GC_NewVar(PyTupleObject, &PyTuple_Type, size);
|
|
|
|
|
if (op == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
for (i=0; i < size; i++)
|
|
|
|
|
op->ob_item[i] = NULL;
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60568 | christian.heimes | 2008-02-04 19:48:38 +0100 (Mon, 04 Feb 2008) | 1 line
Increase debugging to investige failing tests on some build bots
........
r60570 | christian.heimes | 2008-02-04 20:30:05 +0100 (Mon, 04 Feb 2008) | 1 line
Small adjustments for test compact freelist test. It's no passing on Windows as well.
........
r60573 | amaury.forgeotdarc | 2008-02-04 21:53:14 +0100 (Mon, 04 Feb 2008) | 2 lines
Correct quotes in NEWS file
........
r60575 | amaury.forgeotdarc | 2008-02-04 22:45:05 +0100 (Mon, 04 Feb 2008) | 13 lines
#1750076: Debugger did not step on every iteration of a while statement.
The mapping between bytecode offsets and source lines (lnotab) did not contain
an entry for the beginning of the loop.
Now it does, and the lnotab can be a bit larger:
in particular, several statements on the same line generate several entries.
However, this does not bother the settrace function, which will trigger only
one 'line' event.
The lnotab seems to be exactly the same as with python2.4.
........
r60584 | amaury.forgeotdarc | 2008-02-05 01:26:21 +0100 (Tue, 05 Feb 2008) | 3 lines
Change r60575 broke test_compile:
there is no need to emit co_lnotab item when both offsets are zeros.
........
r60587 | skip.montanaro | 2008-02-05 03:32:16 +0100 (Tue, 05 Feb 2008) | 1 line
sync with most recent version from python-mode sf project
........
r60588 | lars.gustaebel | 2008-02-05 12:51:40 +0100 (Tue, 05 Feb 2008) | 5 lines
Issue #2004: Use mode 0700 for temporary directories and default
permissions for missing directories.
(will backport to 2.5)
........
r60590 | georg.brandl | 2008-02-05 13:01:24 +0100 (Tue, 05 Feb 2008) | 2 lines
Convert external links to internal links. Fixes #2010.
........
r60592 | marc-andre.lemburg | 2008-02-05 15:50:40 +0100 (Tue, 05 Feb 2008) | 3 lines
Keep distutils Python 2.1 compatible (or even Python 2.4 in this case).
........
r60593 | andrew.kuchling | 2008-02-05 17:06:57 +0100 (Tue, 05 Feb 2008) | 5 lines
Update PEP URL.
(This code is duplicated between pydoc and DocXMLRPCServer; maybe it
should be refactored as a GHOP project.)
2.5.2 backport candidate.
........
r60596 | guido.van.rossum | 2008-02-05 18:32:15 +0100 (Tue, 05 Feb 2008) | 2 lines
In the experimental 'Scanner' feature, the group count was set wrong.
........
r60602 | facundo.batista | 2008-02-05 20:03:32 +0100 (Tue, 05 Feb 2008) | 3 lines
Issue 1951. Converts wave test cases to unittest.
........
r60603 | georg.brandl | 2008-02-05 20:07:10 +0100 (Tue, 05 Feb 2008) | 2 lines
Actually run the test.
........
r60604 | skip.montanaro | 2008-02-05 20:24:30 +0100 (Tue, 05 Feb 2008) | 2 lines
correct object name
........
r60605 | georg.brandl | 2008-02-05 20:58:17 +0100 (Tue, 05 Feb 2008) | 7 lines
* Use the same code to profile for test_profile and test_cprofile.
* Convert both to unittest.
* Use the same unit testing code.
* Include the expected output in both test files.
* Make it possible to regenerate the expected output by running
the file as a script with an '-r' argument.
........
r60613 | raymond.hettinger | 2008-02-06 02:49:00 +0100 (Wed, 06 Feb 2008) | 1 line
Sync-up with Py3k work.
........
r60614 | christian.heimes | 2008-02-06 13:44:34 +0100 (Wed, 06 Feb 2008) | 1 line
Limit free list of method and builtin function objects to 256 entries each.
........
r60616 | christian.heimes | 2008-02-06 14:33:44 +0100 (Wed, 06 Feb 2008) | 7 lines
Unified naming convention for free lists and their limits. All free lists
in Object/ are named ``free_list``, the counter ``numfree`` and the upper
limit is a macro ``PyName_MAXFREELIST`` inside an #ifndef block.
The chances should make it easier to adjust Python for platforms with
less memory, e.g. mobile phones.
........
2008-02-06 14:31:34 +00:00
|
|
|
#if PyTuple_MAXSAVESIZE > 0
|
2010-05-09 15:52:27 +00:00
|
|
|
if (size == 0) {
|
|
|
|
|
free_list[0] = op;
|
|
|
|
|
++numfree[0];
|
|
|
|
|
Py_INCREF(op); /* extra INCREF so that this is never freed */
|
|
|
|
|
}
|
2009-03-23 19:19:54 +00:00
|
|
|
#endif
|
|
|
|
|
#ifdef SHOW_TRACK_COUNT
|
2010-05-09 15:52:27 +00:00
|
|
|
count_tracked++;
|
1993-10-15 16:18:48 +00:00
|
|
|
#endif
|
2010-05-09 15:52:27 +00:00
|
|
|
_PyObject_GC_TRACK(op);
|
|
|
|
|
return (PyObject *) op;
|
1990-10-14 12:07:46 +00:00
|
|
|
}
|
|
|
|
|
|
2006-02-15 17:27:45 +00:00
|
|
|
Py_ssize_t
|
2000-07-09 07:04:36 +00:00
|
|
|
PyTuple_Size(register PyObject *op)
|
1990-10-14 12:07:46 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
if (!PyTuple_Check(op)) {
|
|
|
|
|
PyErr_BadInternalCall();
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return Py_SIZE(op);
|
1990-10-14 12:07:46 +00:00
|
|
|
}
|
|
|
|
|
|
1997-05-02 03:12:38 +00:00
|
|
|
PyObject *
|
2006-02-15 17:27:45 +00:00
|
|
|
PyTuple_GetItem(register PyObject *op, register Py_ssize_t i)
|
1990-10-14 12:07:46 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
if (!PyTuple_Check(op)) {
|
|
|
|
|
PyErr_BadInternalCall();
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
if (i < 0 || i >= Py_SIZE(op)) {
|
|
|
|
|
PyErr_SetString(PyExc_IndexError, "tuple index out of range");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
return ((PyTupleObject *)op) -> ob_item[i];
|
1990-10-14 12:07:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2006-02-15 17:27:45 +00:00
|
|
|
PyTuple_SetItem(register PyObject *op, register Py_ssize_t i, PyObject *newitem)
|
1990-10-14 12:07:46 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
register PyObject *olditem;
|
|
|
|
|
register PyObject **p;
|
|
|
|
|
if (!PyTuple_Check(op) || op->ob_refcnt != 1) {
|
|
|
|
|
Py_XDECREF(newitem);
|
|
|
|
|
PyErr_BadInternalCall();
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (i < 0 || i >= Py_SIZE(op)) {
|
|
|
|
|
Py_XDECREF(newitem);
|
|
|
|
|
PyErr_SetString(PyExc_IndexError,
|
|
|
|
|
"tuple assignment index out of range");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
p = ((PyTupleObject *)op) -> ob_item + i;
|
|
|
|
|
olditem = *p;
|
|
|
|
|
*p = newitem;
|
|
|
|
|
Py_XDECREF(olditem);
|
|
|
|
|
return 0;
|
1990-10-14 12:07:46 +00:00
|
|
|
}
|
|
|
|
|
|
2009-03-23 18:52:06 +00:00
|
|
|
void
|
|
|
|
|
_PyTuple_MaybeUntrack(PyObject *op)
|
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
PyTupleObject *t;
|
|
|
|
|
Py_ssize_t i, n;
|
|
|
|
|
|
|
|
|
|
if (!PyTuple_CheckExact(op) || !_PyObject_GC_IS_TRACKED(op))
|
|
|
|
|
return;
|
|
|
|
|
t = (PyTupleObject *) op;
|
|
|
|
|
n = Py_SIZE(t);
|
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
|
PyObject *elt = PyTuple_GET_ITEM(t, i);
|
|
|
|
|
/* Tuple with NULL elements aren't
|
|
|
|
|
fully constructed, don't untrack
|
|
|
|
|
them yet. */
|
|
|
|
|
if (!elt ||
|
|
|
|
|
_PyObject_GC_MAY_BE_TRACKED(elt))
|
|
|
|
|
return;
|
|
|
|
|
}
|
2009-03-23 18:52:06 +00:00
|
|
|
#ifdef SHOW_TRACK_COUNT
|
2010-05-09 15:52:27 +00:00
|
|
|
count_tracked--;
|
|
|
|
|
count_untracked++;
|
2009-03-23 18:52:06 +00:00
|
|
|
#endif
|
2010-05-09 15:52:27 +00:00
|
|
|
_PyObject_GC_UNTRACK(op);
|
2009-03-23 18:52:06 +00:00
|
|
|
}
|
|
|
|
|
|
2003-10-12 18:24:34 +00:00
|
|
|
PyObject *
|
2006-02-15 17:27:45 +00:00
|
|
|
PyTuple_Pack(Py_ssize_t n, ...)
|
2003-10-12 18:24:34 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
Py_ssize_t i;
|
|
|
|
|
PyObject *o;
|
|
|
|
|
PyObject *result;
|
|
|
|
|
PyObject **items;
|
|
|
|
|
va_list vargs;
|
2003-10-12 18:24:34 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
va_start(vargs, n);
|
|
|
|
|
result = PyTuple_New(n);
|
2012-09-10 02:54:51 +02:00
|
|
|
if (result == NULL) {
|
|
|
|
|
va_end(vargs);
|
2010-05-09 15:52:27 +00:00
|
|
|
return NULL;
|
2012-09-10 02:54:51 +02:00
|
|
|
}
|
2010-05-09 15:52:27 +00:00
|
|
|
items = ((PyTupleObject *)result)->ob_item;
|
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
|
o = va_arg(vargs, PyObject *);
|
|
|
|
|
Py_INCREF(o);
|
|
|
|
|
items[i] = o;
|
|
|
|
|
}
|
|
|
|
|
va_end(vargs);
|
|
|
|
|
return result;
|
2003-10-12 18:24:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1990-10-14 12:07:46 +00:00
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
|
|
static void
|
2000-07-09 07:04:36 +00:00
|
|
|
tupledealloc(register PyTupleObject *op)
|
1990-10-14 12:07:46 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
register Py_ssize_t i;
|
|
|
|
|
register Py_ssize_t len = Py_SIZE(op);
|
|
|
|
|
PyObject_GC_UnTrack(op);
|
|
|
|
|
Py_TRASHCAN_SAFE_BEGIN(op)
|
|
|
|
|
if (len > 0) {
|
|
|
|
|
i = len;
|
|
|
|
|
while (--i >= 0)
|
|
|
|
|
Py_XDECREF(op->ob_item[i]);
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60568 | christian.heimes | 2008-02-04 19:48:38 +0100 (Mon, 04 Feb 2008) | 1 line
Increase debugging to investige failing tests on some build bots
........
r60570 | christian.heimes | 2008-02-04 20:30:05 +0100 (Mon, 04 Feb 2008) | 1 line
Small adjustments for test compact freelist test. It's no passing on Windows as well.
........
r60573 | amaury.forgeotdarc | 2008-02-04 21:53:14 +0100 (Mon, 04 Feb 2008) | 2 lines
Correct quotes in NEWS file
........
r60575 | amaury.forgeotdarc | 2008-02-04 22:45:05 +0100 (Mon, 04 Feb 2008) | 13 lines
#1750076: Debugger did not step on every iteration of a while statement.
The mapping between bytecode offsets and source lines (lnotab) did not contain
an entry for the beginning of the loop.
Now it does, and the lnotab can be a bit larger:
in particular, several statements on the same line generate several entries.
However, this does not bother the settrace function, which will trigger only
one 'line' event.
The lnotab seems to be exactly the same as with python2.4.
........
r60584 | amaury.forgeotdarc | 2008-02-05 01:26:21 +0100 (Tue, 05 Feb 2008) | 3 lines
Change r60575 broke test_compile:
there is no need to emit co_lnotab item when both offsets are zeros.
........
r60587 | skip.montanaro | 2008-02-05 03:32:16 +0100 (Tue, 05 Feb 2008) | 1 line
sync with most recent version from python-mode sf project
........
r60588 | lars.gustaebel | 2008-02-05 12:51:40 +0100 (Tue, 05 Feb 2008) | 5 lines
Issue #2004: Use mode 0700 for temporary directories and default
permissions for missing directories.
(will backport to 2.5)
........
r60590 | georg.brandl | 2008-02-05 13:01:24 +0100 (Tue, 05 Feb 2008) | 2 lines
Convert external links to internal links. Fixes #2010.
........
r60592 | marc-andre.lemburg | 2008-02-05 15:50:40 +0100 (Tue, 05 Feb 2008) | 3 lines
Keep distutils Python 2.1 compatible (or even Python 2.4 in this case).
........
r60593 | andrew.kuchling | 2008-02-05 17:06:57 +0100 (Tue, 05 Feb 2008) | 5 lines
Update PEP URL.
(This code is duplicated between pydoc and DocXMLRPCServer; maybe it
should be refactored as a GHOP project.)
2.5.2 backport candidate.
........
r60596 | guido.van.rossum | 2008-02-05 18:32:15 +0100 (Tue, 05 Feb 2008) | 2 lines
In the experimental 'Scanner' feature, the group count was set wrong.
........
r60602 | facundo.batista | 2008-02-05 20:03:32 +0100 (Tue, 05 Feb 2008) | 3 lines
Issue 1951. Converts wave test cases to unittest.
........
r60603 | georg.brandl | 2008-02-05 20:07:10 +0100 (Tue, 05 Feb 2008) | 2 lines
Actually run the test.
........
r60604 | skip.montanaro | 2008-02-05 20:24:30 +0100 (Tue, 05 Feb 2008) | 2 lines
correct object name
........
r60605 | georg.brandl | 2008-02-05 20:58:17 +0100 (Tue, 05 Feb 2008) | 7 lines
* Use the same code to profile for test_profile and test_cprofile.
* Convert both to unittest.
* Use the same unit testing code.
* Include the expected output in both test files.
* Make it possible to regenerate the expected output by running
the file as a script with an '-r' argument.
........
r60613 | raymond.hettinger | 2008-02-06 02:49:00 +0100 (Wed, 06 Feb 2008) | 1 line
Sync-up with Py3k work.
........
r60614 | christian.heimes | 2008-02-06 13:44:34 +0100 (Wed, 06 Feb 2008) | 1 line
Limit free list of method and builtin function objects to 256 entries each.
........
r60616 | christian.heimes | 2008-02-06 14:33:44 +0100 (Wed, 06 Feb 2008) | 7 lines
Unified naming convention for free lists and their limits. All free lists
in Object/ are named ``free_list``, the counter ``numfree`` and the upper
limit is a macro ``PyName_MAXFREELIST`` inside an #ifndef block.
The chances should make it easier to adjust Python for platforms with
less memory, e.g. mobile phones.
........
2008-02-06 14:31:34 +00:00
|
|
|
#if PyTuple_MAXSAVESIZE > 0
|
2010-05-09 15:52:27 +00:00
|
|
|
if (len < PyTuple_MAXSAVESIZE &&
|
|
|
|
|
numfree[len] < PyTuple_MAXFREELIST &&
|
|
|
|
|
Py_TYPE(op) == &PyTuple_Type)
|
|
|
|
|
{
|
|
|
|
|
op->ob_item[0] = (PyObject *) free_list[len];
|
|
|
|
|
numfree[len]++;
|
|
|
|
|
free_list[len] = op;
|
|
|
|
|
goto done; /* return */
|
|
|
|
|
}
|
1993-10-15 16:18:48 +00:00
|
|
|
#endif
|
2010-05-09 15:52:27 +00:00
|
|
|
}
|
|
|
|
|
Py_TYPE(op)->tp_free((PyObject *)op);
|
2000-03-13 16:01:29 +00:00
|
|
|
done:
|
2010-05-09 15:52:27 +00:00
|
|
|
Py_TRASHCAN_SAFE_END(op)
|
1990-10-14 12:07:46 +00:00
|
|
|
}
|
|
|
|
|
|
1997-05-02 03:12:38 +00:00
|
|
|
static PyObject *
|
2000-07-09 07:04:36 +00:00
|
|
|
tuplerepr(PyTupleObject *v)
|
1990-10-14 12:07:46 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
Py_ssize_t i, n;
|
2011-10-06 18:57:27 +02:00
|
|
|
PyObject *s = NULL;
|
|
|
|
|
_PyAccu acc;
|
|
|
|
|
static PyObject *sep = NULL;
|
2001-06-16 05:11:17 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
n = Py_SIZE(v);
|
|
|
|
|
if (n == 0)
|
|
|
|
|
return PyUnicode_FromString("()");
|
2001-06-16 05:11:17 +00:00
|
|
|
|
2011-10-06 18:57:27 +02:00
|
|
|
if (sep == NULL) {
|
|
|
|
|
sep = PyUnicode_FromString(", ");
|
|
|
|
|
if (sep == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
/* While not mutable, it is still possible to end up with a cycle in a
|
|
|
|
|
tuple through an object that stores itself within a tuple (and thus
|
|
|
|
|
infinitely asks for the repr of itself). This should only be
|
|
|
|
|
possible within a type. */
|
|
|
|
|
i = Py_ReprEnter((PyObject *)v);
|
|
|
|
|
if (i != 0) {
|
|
|
|
|
return i > 0 ? PyUnicode_FromString("(...)") : NULL;
|
|
|
|
|
}
|
Merged revisions 58221-58741 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r58221 | georg.brandl | 2007-09-20 10:57:59 -0700 (Thu, 20 Sep 2007) | 2 lines
Patch #1181: add os.environ.clear() method.
........
r58225 | sean.reifschneider | 2007-09-20 23:33:28 -0700 (Thu, 20 Sep 2007) | 3 lines
Issue1704287: "make install" fails unless you do "make" first. Make
oldsharedmods and sharedmods in "libinstall".
........
r58232 | guido.van.rossum | 2007-09-22 13:18:03 -0700 (Sat, 22 Sep 2007) | 4 lines
Patch # 188 by Philip Jenvey.
Make tell() mark CRLF as a newline.
With unit test.
........
r58242 | georg.brandl | 2007-09-24 10:55:47 -0700 (Mon, 24 Sep 2007) | 2 lines
Fix typo and double word.
........
r58245 | georg.brandl | 2007-09-24 10:59:28 -0700 (Mon, 24 Sep 2007) | 2 lines
#1196: document default radix for int().
........
r58247 | georg.brandl | 2007-09-24 11:08:24 -0700 (Mon, 24 Sep 2007) | 2 lines
#1177: accept 2xx responses for https too, not only http.
........
r58249 | andrew.kuchling | 2007-09-24 16:45:51 -0700 (Mon, 24 Sep 2007) | 1 line
Remove stray odd character; grammar fix
........
r58250 | andrew.kuchling | 2007-09-24 16:46:28 -0700 (Mon, 24 Sep 2007) | 1 line
Typo fix
........
r58251 | andrew.kuchling | 2007-09-24 17:09:42 -0700 (Mon, 24 Sep 2007) | 1 line
Add various items
........
r58268 | vinay.sajip | 2007-09-26 22:34:45 -0700 (Wed, 26 Sep 2007) | 1 line
Change to flush and close logic to fix #1760556.
........
r58269 | vinay.sajip | 2007-09-26 22:38:51 -0700 (Wed, 26 Sep 2007) | 1 line
Change to basicConfig() to fix #1021.
........
r58270 | georg.brandl | 2007-09-26 23:26:58 -0700 (Wed, 26 Sep 2007) | 2 lines
#1208: document match object's boolean value.
........
r58271 | vinay.sajip | 2007-09-26 23:56:13 -0700 (Wed, 26 Sep 2007) | 1 line
Minor date change.
........
r58272 | vinay.sajip | 2007-09-27 00:35:10 -0700 (Thu, 27 Sep 2007) | 1 line
Change to LogRecord.__init__() to fix #1206. Note that archaic use of type(x) == types.DictType is because of keeping 1.5.2 compatibility. While this is much less relevant these days, there probably needs to be a separate commit for removing all archaic constructs at the same time.
........
r58288 | brett.cannon | 2007-09-30 12:45:10 -0700 (Sun, 30 Sep 2007) | 9 lines
tuple.__repr__ did not consider a reference loop as it is not possible from
Python code; but it is possible from C. object.__str__ had the issue of not
expecting a type to doing something within it's tp_str implementation that
could trigger an infinite recursion, but it could in C code.. Both found
thanks to BaseException and how it handles its repr.
Closes issue #1686386. Thanks to Thomas Herve for taking an initial stab at
coming up with a solution.
........
r58289 | brett.cannon | 2007-09-30 13:37:19 -0700 (Sun, 30 Sep 2007) | 3 lines
Fix error introduced by r58288; if a tuple is length 0 return its repr and
don't worry about any self-referring tuples.
........
r58294 | facundo.batista | 2007-10-02 10:01:24 -0700 (Tue, 02 Oct 2007) | 11 lines
Made the various is_* operations return booleans. This was discussed
with Cawlishaw by mail, and he basically confirmed that to these is_*
operations, there's no need to return Decimal(0) and Decimal(1) if
the language supports the False and True booleans.
Also added a few tests for the these functions in extra.decTest, since
they are mostly untested (apart from the doctests).
Thanks Mark Dickinson
........
r58295 | facundo.batista | 2007-10-02 11:21:18 -0700 (Tue, 02 Oct 2007) | 4 lines
Added a class to store the digits of log(10), so that they can be made
available when necessary without recomputing. Thanks Mark Dickinson
........
r58299 | mark.summerfield | 2007-10-03 01:53:21 -0700 (Wed, 03 Oct 2007) | 4 lines
Added note in footnote about string comparisons about
unicodedata.normalize().
........
r58304 | raymond.hettinger | 2007-10-03 14:18:11 -0700 (Wed, 03 Oct 2007) | 1 line
enumerate() is no longer bounded to using sequences shorter than LONG_MAX. The possibility of overflow was sending some newsgroup posters into a tizzy.
........
r58305 | raymond.hettinger | 2007-10-03 17:20:27 -0700 (Wed, 03 Oct 2007) | 1 line
itertools.count() no longer limited to sys.maxint.
........
r58306 | kurt.kaiser | 2007-10-03 18:49:54 -0700 (Wed, 03 Oct 2007) | 3 lines
Assume that the user knows when he wants to end the line; don't insert
something he didn't select or complete.
........
r58307 | kurt.kaiser | 2007-10-03 19:07:50 -0700 (Wed, 03 Oct 2007) | 2 lines
Remove unused theme that was causing a fault in p3k.
........
r58308 | kurt.kaiser | 2007-10-03 19:09:17 -0700 (Wed, 03 Oct 2007) | 2 lines
Clean up EditorWindow close.
........
r58309 | kurt.kaiser | 2007-10-03 19:53:07 -0700 (Wed, 03 Oct 2007) | 7 lines
textView cleanup. Patch 1718043 Tal Einat.
M idlelib/EditorWindow.py
M idlelib/aboutDialog.py
M idlelib/textView.py
M idlelib/NEWS.txt
........
r58310 | kurt.kaiser | 2007-10-03 20:11:12 -0700 (Wed, 03 Oct 2007) | 3 lines
configDialog cleanup. Patch 1730217 Tal Einat.
........
r58311 | neal.norwitz | 2007-10-03 23:00:48 -0700 (Wed, 03 Oct 2007) | 4 lines
Coverity #151: Remove deadcode.
All this code already exists above starting at line 653.
........
r58325 | fred.drake | 2007-10-04 19:46:12 -0700 (Thu, 04 Oct 2007) | 1 line
wrap lines to <80 characters before fixing errors
........
r58326 | raymond.hettinger | 2007-10-04 19:47:07 -0700 (Thu, 04 Oct 2007) | 6 lines
Add __asdict__() to NamedTuple and refine the docs.
Add maxlen support to deque() and fixup docs.
Partially fix __reduce__(). The None as a third arg was no longer supported.
Still needs work on __reduce__() to handle recursive inputs.
........
r58327 | fred.drake | 2007-10-04 19:48:32 -0700 (Thu, 04 Oct 2007) | 3 lines
move descriptions of ac_(in|out)_buffer_size to the right place
http://bugs.python.org/issue1053
........
r58329 | neal.norwitz | 2007-10-04 20:39:17 -0700 (Thu, 04 Oct 2007) | 3 lines
dict could be NULL, so we need to XDECREF.
Fix a compiler warning about passing a PyTypeObject* instead of PyObject*.
........
r58330 | neal.norwitz | 2007-10-04 20:41:19 -0700 (Thu, 04 Oct 2007) | 2 lines
Fix Coverity #158: Check the correct variable.
........
r58332 | neal.norwitz | 2007-10-04 22:01:38 -0700 (Thu, 04 Oct 2007) | 7 lines
Fix Coverity #159.
This code was broken if save() returned a negative number since i contained
a boolean value and then we compared i < 0 which should never be true.
Will backport (assuming it's necessary)
........
r58334 | neal.norwitz | 2007-10-04 22:29:17 -0700 (Thu, 04 Oct 2007) | 1 line
Add a note about fixing some more warnings found by Coverity.
........
r58338 | raymond.hettinger | 2007-10-05 12:07:31 -0700 (Fri, 05 Oct 2007) | 1 line
Restore BEGIN/END THREADS macros which were squashed in the previous checkin
........
r58343 | gregory.p.smith | 2007-10-06 00:48:10 -0700 (Sat, 06 Oct 2007) | 3 lines
Stab in the dark attempt to fix the test_bsddb3 failure on sparc and S-390
ubuntu buildbots.
........
r58344 | gregory.p.smith | 2007-10-06 00:51:59 -0700 (Sat, 06 Oct 2007) | 2 lines
Allows BerkeleyDB 4.6.x >= 4.6.21 for the bsddb module.
........
r58348 | gregory.p.smith | 2007-10-06 08:47:37 -0700 (Sat, 06 Oct 2007) | 3 lines
Use the host the author likely meant in the first place. pop.gmail.com is
reliable. gmail.org is someones personal domain.
........
r58351 | neal.norwitz | 2007-10-06 12:16:28 -0700 (Sat, 06 Oct 2007) | 3 lines
Ensure that this test will pass even if another test left an unwritable TESTFN.
Also use the safe unlink in test_support instead of rolling our own here.
........
r58368 | georg.brandl | 2007-10-08 00:50:24 -0700 (Mon, 08 Oct 2007) | 3 lines
#1123: fix the docs for the str.split(None, sep) case.
Also expand a few other methods' docs, which had more info in the deprecated string module docs.
........
r58369 | georg.brandl | 2007-10-08 01:06:05 -0700 (Mon, 08 Oct 2007) | 2 lines
Update docstring of sched, also remove an unused assignment.
........
r58370 | raymond.hettinger | 2007-10-08 02:14:28 -0700 (Mon, 08 Oct 2007) | 5 lines
Add comments to NamedTuple code.
Let the field spec be either a string or a non-string sequence (suggested by Martin Blais with use cases).
Improve the error message in the case of a SyntaxError (caused by a duplicate field name).
........
r58371 | raymond.hettinger | 2007-10-08 02:56:29 -0700 (Mon, 08 Oct 2007) | 1 line
Missed a line in the docs
........
r58372 | raymond.hettinger | 2007-10-08 03:11:51 -0700 (Mon, 08 Oct 2007) | 1 line
Better variable names
........
r58376 | georg.brandl | 2007-10-08 07:12:47 -0700 (Mon, 08 Oct 2007) | 3 lines
#1199: docs for tp_as_{number,sequence,mapping}, by Amaury Forgeot d'Arc.
No need to merge this to py3k!
........
r58380 | raymond.hettinger | 2007-10-08 14:26:58 -0700 (Mon, 08 Oct 2007) | 1 line
Eliminate camelcase function name
........
r58381 | andrew.kuchling | 2007-10-08 16:23:03 -0700 (Mon, 08 Oct 2007) | 1 line
Eliminate camelcase function name
........
r58382 | raymond.hettinger | 2007-10-08 18:36:23 -0700 (Mon, 08 Oct 2007) | 1 line
Make the error messages more specific
........
r58384 | gregory.p.smith | 2007-10-08 23:02:21 -0700 (Mon, 08 Oct 2007) | 10 lines
Splits Modules/_bsddb.c up into bsddb.h and _bsddb.c and adds a C API
object available as bsddb.db.api. This is based on the patch submitted
by Duncan Grisby here:
http://sourceforge.net/tracker/index.php?func=detail&aid=1551895&group_id=13900&atid=313900
See this thread for additional info:
http://sourceforge.net/mailarchive/forum.php?thread_name=E1GAVDK-0002rk-Iw%40apasphere.com&forum_name=pybsddb-users
It also cleans up the code a little by removing some ifdef/endifs for
python prior to 2.1 and for unsupported Berkeley DB <= 3.2.
........
r58385 | gregory.p.smith | 2007-10-08 23:50:43 -0700 (Mon, 08 Oct 2007) | 5 lines
Fix a double free when positioning a database cursor to a non-existant
string key (and probably a few other situations with string keys).
This was reported with a patch as pybsddb sourceforge bug 1708868 by
jjjhhhlll at gmail.
........
r58386 | gregory.p.smith | 2007-10-09 00:19:11 -0700 (Tue, 09 Oct 2007) | 3 lines
Use the highest cPickle protocol in bsddb.dbshelve. This comes from
sourceforge pybsddb patch 1551443 by w_barnes.
........
r58394 | gregory.p.smith | 2007-10-09 11:26:02 -0700 (Tue, 09 Oct 2007) | 2 lines
remove another sleepycat reference
........
r58396 | kurt.kaiser | 2007-10-09 12:31:30 -0700 (Tue, 09 Oct 2007) | 3 lines
Allow interrupt only when executing user code in subprocess
Patch 1225 Tal Einat modified from IDLE-Spoon.
........
r58399 | brett.cannon | 2007-10-09 17:07:50 -0700 (Tue, 09 Oct 2007) | 5 lines
Remove file-level typedefs that were inconsistently used throughout the file.
Just move over to the public API names.
Closes issue1238.
........
r58401 | raymond.hettinger | 2007-10-09 17:26:46 -0700 (Tue, 09 Oct 2007) | 1 line
Accept Jim Jewett's api suggestion to use None instead of -1 to indicate unbounded deques.
........
r58403 | kurt.kaiser | 2007-10-09 17:55:40 -0700 (Tue, 09 Oct 2007) | 2 lines
Allow cursor color change w/o restart. Patch 1725576 Tal Einat.
........
r58404 | kurt.kaiser | 2007-10-09 18:06:47 -0700 (Tue, 09 Oct 2007) | 2 lines
show paste if > 80 columns. Patch 1659326 Tal Einat.
........
r58415 | thomas.heller | 2007-10-11 12:51:32 -0700 (Thu, 11 Oct 2007) | 5 lines
On OS X, use os.uname() instead of gestalt.sysv(...) to get the
operating system version. This allows to use ctypes when Python
was configured with --disable-toolbox-glue.
........
r58419 | neal.norwitz | 2007-10-11 20:01:01 -0700 (Thu, 11 Oct 2007) | 1 line
Get rid of warning about not being able to create an existing directory.
........
r58420 | neal.norwitz | 2007-10-11 20:01:30 -0700 (Thu, 11 Oct 2007) | 1 line
Get rid of warnings on a bunch of platforms by using a proper prototype.
........
r58421 | neal.norwitz | 2007-10-11 20:01:54 -0700 (Thu, 11 Oct 2007) | 4 lines
Get rid of compiler warning about retval being used (returned) without
being initialized. (gcc warning and Coverity 202)
........
r58422 | neal.norwitz | 2007-10-11 20:03:23 -0700 (Thu, 11 Oct 2007) | 1 line
Fix Coverity 168: Close the file before returning (exiting).
........
r58423 | neal.norwitz | 2007-10-11 20:04:18 -0700 (Thu, 11 Oct 2007) | 4 lines
Fix Coverity 180: Don't overallocate. We don't need structs, but pointers.
Also fix a memory leak.
........
r58424 | neal.norwitz | 2007-10-11 20:05:19 -0700 (Thu, 11 Oct 2007) | 5 lines
Fix Coverity 185-186: If the passed in FILE is NULL, uninitialized memory
would be accessed.
Will backport.
........
r58425 | neal.norwitz | 2007-10-11 20:52:34 -0700 (Thu, 11 Oct 2007) | 1 line
Get this module to compile with bsddb versions prior to 4.3
........
r58430 | martin.v.loewis | 2007-10-12 01:56:52 -0700 (Fri, 12 Oct 2007) | 3 lines
Bug #1216: Restore support for Visual Studio 2002.
Will backport to 2.5.
........
r58433 | raymond.hettinger | 2007-10-12 10:53:11 -0700 (Fri, 12 Oct 2007) | 1 line
Fix test of count.__repr__() to ignore the 'L' if the count is a long
........
r58434 | gregory.p.smith | 2007-10-12 11:44:06 -0700 (Fri, 12 Oct 2007) | 4 lines
Fixes http://bugs.python.org/issue1233 - bsddb.dbshelve.DBShelf.append
was useless due to inverted logic. Also adds a test case for RECNO dbs
to test_dbshelve.
........
r58445 | georg.brandl | 2007-10-13 06:20:03 -0700 (Sat, 13 Oct 2007) | 2 lines
Fix email example.
........
r58450 | gregory.p.smith | 2007-10-13 16:02:05 -0700 (Sat, 13 Oct 2007) | 2 lines
Fix an uncollectable reference leak in bsddb.db.DBShelf.append
........
r58453 | neal.norwitz | 2007-10-13 17:18:40 -0700 (Sat, 13 Oct 2007) | 8 lines
Let the O/S supply a port if none of the default ports can be used.
This should make the tests more robust at the expense of allowing
tests to be sloppier by not requiring them to cleanup after themselves.
(It will legitamitely help when running two test suites simultaneously
or if another process is already using one of the predefined ports.)
Also simplifies (slightLy) the exception handling elsewhere.
........
r58459 | neal.norwitz | 2007-10-14 11:30:21 -0700 (Sun, 14 Oct 2007) | 2 lines
Don't raise a string exception, they don't work anymore.
........
r58460 | neal.norwitz | 2007-10-14 11:40:37 -0700 (Sun, 14 Oct 2007) | 1 line
Use unittest for assertions
........
r58468 | armin.rigo | 2007-10-15 00:48:35 -0700 (Mon, 15 Oct 2007) | 2 lines
test_bigbits was not testing what it seemed to.
........
r58471 | guido.van.rossum | 2007-10-15 08:54:11 -0700 (Mon, 15 Oct 2007) | 3 lines
Change a PyErr_Print() into a PyErr_Clear(),
per discussion in issue 1031213.
........
r58500 | raymond.hettinger | 2007-10-16 12:18:30 -0700 (Tue, 16 Oct 2007) | 1 line
Improve error messages
........
r58506 | raymond.hettinger | 2007-10-16 14:28:32 -0700 (Tue, 16 Oct 2007) | 1 line
More docs, error messages, and tests
........
r58507 | andrew.kuchling | 2007-10-16 15:58:03 -0700 (Tue, 16 Oct 2007) | 1 line
Add items
........
r58508 | brett.cannon | 2007-10-16 16:24:06 -0700 (Tue, 16 Oct 2007) | 3 lines
Remove ``:const:`` notation on None in parameter list. Since the markup is not
rendered for parameters it just showed up as ``:const:`None` `` in the output.
........
r58509 | brett.cannon | 2007-10-16 16:26:45 -0700 (Tue, 16 Oct 2007) | 3 lines
Re-order some functions whose parameters differ between PyObject and const char
* so that they are next to each other.
........
r58522 | armin.rigo | 2007-10-17 11:46:37 -0700 (Wed, 17 Oct 2007) | 5 lines
Fix the overflow checking of list_repeat.
Introduce overflow checking into list_inplace_repeat.
Backport candidate, possibly.
........
r58530 | facundo.batista | 2007-10-17 20:16:03 -0700 (Wed, 17 Oct 2007) | 7 lines
Issue #1580738. When HTTPConnection reads the whole stream with read(),
it closes itself. When the stream is read in several calls to read(n),
it should behave in the same way if HTTPConnection knows where the end
of the stream is (through self.length). Added a test case for this
behaviour.
........
r58531 | facundo.batista | 2007-10-17 20:44:48 -0700 (Wed, 17 Oct 2007) | 3 lines
Issue 1289, just a typo.
........
r58532 | gregory.p.smith | 2007-10-18 00:56:54 -0700 (Thu, 18 Oct 2007) | 4 lines
cleanup test_dbtables to use mkdtemp. cleanup dbtables to pass txn as a
keyword argument whenever possible to avoid bugs and confusion. (dbtables.py
line 447 self.db.get using txn as a non-keyword was an actual bug due to this)
........
r58533 | gregory.p.smith | 2007-10-18 01:34:20 -0700 (Thu, 18 Oct 2007) | 4 lines
Fix a weird bug in dbtables: if it chose a random rowid string that contained
NULL bytes it would cause the database all sorts of problems in the future
leading to very strange random failures and corrupt dbtables.bsdTableDb dbs.
........
r58534 | gregory.p.smith | 2007-10-18 09:32:02 -0700 (Thu, 18 Oct 2007) | 3 lines
A cleaner fix than the one committed last night. Generate random rowids that
do not contain null bytes.
........
r58537 | gregory.p.smith | 2007-10-18 10:17:57 -0700 (Thu, 18 Oct 2007) | 2 lines
mention bsddb fixes.
........
r58538 | raymond.hettinger | 2007-10-18 14:13:06 -0700 (Thu, 18 Oct 2007) | 1 line
Remove useless warning
........
r58539 | gregory.p.smith | 2007-10-19 00:31:20 -0700 (Fri, 19 Oct 2007) | 2 lines
squelch the warning that this test is supposed to trigger.
........
r58542 | georg.brandl | 2007-10-19 05:32:39 -0700 (Fri, 19 Oct 2007) | 2 lines
Clarify wording for apply().
........
r58544 | mark.summerfield | 2007-10-19 05:48:17 -0700 (Fri, 19 Oct 2007) | 3 lines
Added a cross-ref to each other.
........
r58545 | georg.brandl | 2007-10-19 10:38:49 -0700 (Fri, 19 Oct 2007) | 2 lines
#1284: "S" means "seen", not unread.
........
r58548 | thomas.heller | 2007-10-19 11:11:41 -0700 (Fri, 19 Oct 2007) | 4 lines
Fix ctypes on 32-bit systems when Python is configured --with-system-ffi.
See also https://bugs.launchpad.net/bugs/72505.
Ported from release25-maint branch.
........
r58550 | facundo.batista | 2007-10-19 12:25:57 -0700 (Fri, 19 Oct 2007) | 8 lines
The constructor from tuple was way too permissive: it allowed bad
coefficient numbers, floats in the sign, and other details that
generated directly the wrong number in the best case, or triggered
misfunctionality in the alorithms.
Test cases added for these issues. Thanks Mark Dickinson.
........
r58559 | georg.brandl | 2007-10-20 06:22:53 -0700 (Sat, 20 Oct 2007) | 2 lines
Fix code being interpreted as a target.
........
r58561 | georg.brandl | 2007-10-20 06:36:24 -0700 (Sat, 20 Oct 2007) | 2 lines
Document new "cmdoption" directive.
........
r58562 | georg.brandl | 2007-10-20 08:21:22 -0700 (Sat, 20 Oct 2007) | 2 lines
Make a path more Unix-standardy.
........
r58564 | georg.brandl | 2007-10-20 10:51:39 -0700 (Sat, 20 Oct 2007) | 2 lines
Document new directive "envvar".
........
r58567 | georg.brandl | 2007-10-20 11:08:14 -0700 (Sat, 20 Oct 2007) | 6 lines
* Add new toplevel chapter, "Using Python." (how to install,
configure and setup python on different platforms -- at least
in theory.)
* Move the Python on Mac docs in that chapter.
* Add a new chapter about the command line invocation, by stargaming.
........
r58568 | georg.brandl | 2007-10-20 11:33:20 -0700 (Sat, 20 Oct 2007) | 2 lines
Change title, for now.
........
r58569 | georg.brandl | 2007-10-20 11:39:25 -0700 (Sat, 20 Oct 2007) | 2 lines
Add entry to ACKS.
........
r58570 | georg.brandl | 2007-10-20 12:05:45 -0700 (Sat, 20 Oct 2007) | 2 lines
Clarify -E docs.
........
r58571 | georg.brandl | 2007-10-20 12:08:36 -0700 (Sat, 20 Oct 2007) | 2 lines
Even more clarification.
........
r58572 | andrew.kuchling | 2007-10-20 12:25:37 -0700 (Sat, 20 Oct 2007) | 1 line
Fix protocol name
........
r58573 | andrew.kuchling | 2007-10-20 12:35:18 -0700 (Sat, 20 Oct 2007) | 1 line
Various items
........
r58574 | andrew.kuchling | 2007-10-20 12:39:35 -0700 (Sat, 20 Oct 2007) | 1 line
Use correct header line
........
r58576 | armin.rigo | 2007-10-21 02:14:15 -0700 (Sun, 21 Oct 2007) | 3 lines
Add a crasher for the long-standing issue with closing a file
while another thread uses it.
........
r58577 | georg.brandl | 2007-10-21 03:01:56 -0700 (Sun, 21 Oct 2007) | 2 lines
Remove duplicate crasher.
........
r58578 | georg.brandl | 2007-10-21 03:24:20 -0700 (Sun, 21 Oct 2007) | 2 lines
Unify "byte code" to "bytecode". Also sprinkle :term: markup for it.
........
r58579 | georg.brandl | 2007-10-21 03:32:54 -0700 (Sun, 21 Oct 2007) | 2 lines
Add markup to new function descriptions.
........
r58580 | georg.brandl | 2007-10-21 03:45:46 -0700 (Sun, 21 Oct 2007) | 2 lines
Add :term:s for descriptors.
........
r58581 | georg.brandl | 2007-10-21 03:46:24 -0700 (Sun, 21 Oct 2007) | 2 lines
Unify "file-descriptor" to "file descriptor".
........
r58582 | georg.brandl | 2007-10-21 03:52:38 -0700 (Sun, 21 Oct 2007) | 2 lines
Add :term: for generators.
........
r58583 | georg.brandl | 2007-10-21 05:10:28 -0700 (Sun, 21 Oct 2007) | 2 lines
Add :term:s for iterator.
........
r58584 | georg.brandl | 2007-10-21 05:15:05 -0700 (Sun, 21 Oct 2007) | 2 lines
Add :term:s for "new-style class".
........
r58588 | neal.norwitz | 2007-10-21 21:47:54 -0700 (Sun, 21 Oct 2007) | 1 line
Add Chris Monson so he can edit PEPs.
........
r58594 | guido.van.rossum | 2007-10-22 09:27:19 -0700 (Mon, 22 Oct 2007) | 4 lines
Issue #1307, patch by Derek Shockey.
When "MAIL" is received without args, an exception happens instead of
sending a 501 syntax error response.
........
r58598 | travis.oliphant | 2007-10-22 19:40:56 -0700 (Mon, 22 Oct 2007) | 1 line
Add phuang patch from Issue 708374 which adds offset parameter to mmap module.
........
r58601 | neal.norwitz | 2007-10-22 22:44:27 -0700 (Mon, 22 Oct 2007) | 2 lines
Bug #1313, fix typo (wrong variable name) in example.
........
r58609 | georg.brandl | 2007-10-23 11:21:35 -0700 (Tue, 23 Oct 2007) | 2 lines
Update Pygments version from externals.
........
r58618 | guido.van.rossum | 2007-10-23 12:25:41 -0700 (Tue, 23 Oct 2007) | 3 lines
Issue 1307 by Derek Shockey, fox the same bug for RCPT.
Neal: please backport!
........
r58620 | raymond.hettinger | 2007-10-23 13:37:41 -0700 (Tue, 23 Oct 2007) | 1 line
Shorter name for namedtuple()
........
r58621 | andrew.kuchling | 2007-10-23 13:55:47 -0700 (Tue, 23 Oct 2007) | 1 line
Update name
........
r58622 | raymond.hettinger | 2007-10-23 14:23:07 -0700 (Tue, 23 Oct 2007) | 1 line
Fixup news entry
........
r58623 | raymond.hettinger | 2007-10-23 18:28:33 -0700 (Tue, 23 Oct 2007) | 1 line
Optimize sum() for integer and float inputs.
........
r58624 | raymond.hettinger | 2007-10-23 19:05:51 -0700 (Tue, 23 Oct 2007) | 1 line
Fixup error return and add support for intermixed ints and floats/
........
r58628 | vinay.sajip | 2007-10-24 03:47:06 -0700 (Wed, 24 Oct 2007) | 1 line
Bug #1321: Fixed logic error in TimedRotatingFileHandler.__init__()
........
r58641 | facundo.batista | 2007-10-24 12:11:08 -0700 (Wed, 24 Oct 2007) | 4 lines
Issue 1290. CharacterData.__repr__ was constructing a string
in response that keeped having a non-ascii character.
........
r58643 | thomas.heller | 2007-10-24 12:50:45 -0700 (Wed, 24 Oct 2007) | 1 line
Added unittest for calling a function with paramflags (backport from py3k branch).
........
r58645 | matthias.klose | 2007-10-24 13:00:44 -0700 (Wed, 24 Oct 2007) | 2 lines
- Build using system ffi library on arm*-linux*.
........
r58651 | georg.brandl | 2007-10-24 14:40:38 -0700 (Wed, 24 Oct 2007) | 2 lines
Bug #1287: make os.environ.pop() work as expected.
........
r58652 | raymond.hettinger | 2007-10-24 19:26:58 -0700 (Wed, 24 Oct 2007) | 1 line
Missing DECREFs
........
r58653 | matthias.klose | 2007-10-24 23:37:24 -0700 (Wed, 24 Oct 2007) | 2 lines
- Build using system ffi library on arm*-linux*, pass --with-system-ffi to CONFIG_ARGS
........
r58655 | thomas.heller | 2007-10-25 12:47:32 -0700 (Thu, 25 Oct 2007) | 2 lines
ffi_type_longdouble may be already #defined.
See issue 1324.
........
r58656 | kurt.kaiser | 2007-10-25 15:43:45 -0700 (Thu, 25 Oct 2007) | 3 lines
Correct an ancient bug in an unused path by removing that path: register() is
now idempotent.
........
r58660 | kurt.kaiser | 2007-10-25 17:10:09 -0700 (Thu, 25 Oct 2007) | 4 lines
1. Add comments to provide top-level documentation.
2. Refactor to use more descriptive names.
3. Enhance tests in main().
........
r58675 | georg.brandl | 2007-10-26 11:30:41 -0700 (Fri, 26 Oct 2007) | 2 lines
Fix new pop() method on os.environ on ignorecase-platforms.
........
r58696 | neal.norwitz | 2007-10-27 15:32:21 -0700 (Sat, 27 Oct 2007) | 1 line
Update URL for Pygments. 0.8.1 is no longer available
........
r58697 | hyeshik.chang | 2007-10-28 04:19:02 -0700 (Sun, 28 Oct 2007) | 3 lines
- Add support for FreeBSD 8 which is recently forked from FreeBSD 7.
- Regenerate IN module for most recent maintenance tree of FreeBSD 6 and 7.
........
r58698 | hyeshik.chang | 2007-10-28 05:38:09 -0700 (Sun, 28 Oct 2007) | 2 lines
Enable platform-specific tweaks for FreeBSD 8 (exactly same to FreeBSD 7's yet)
........
r58700 | kurt.kaiser | 2007-10-28 12:03:59 -0700 (Sun, 28 Oct 2007) | 2 lines
Add confirmation dialog before printing. Patch 1717170 Tal Einat.
........
r58706 | guido.van.rossum | 2007-10-29 13:52:45 -0700 (Mon, 29 Oct 2007) | 3 lines
Patch 1353 by Jacob Winther.
Add mp4 mapping to mimetypes.py.
........
r58709 | guido.van.rossum | 2007-10-29 15:15:05 -0700 (Mon, 29 Oct 2007) | 6 lines
Backport fixes for the code that decodes octal escapes (and for PyString
also hex escapes) -- this was reaching beyond the end of the input string
buffer, even though it is not supposed to be \0-terminated.
This has no visible effect but is clearly the correct thing to do.
(In 3.0 it had a visible effect after removing ob_sstate from PyString.)
........
r58710 | kurt.kaiser | 2007-10-29 19:38:54 -0700 (Mon, 29 Oct 2007) | 7 lines
check in Tal Einat's update to tabpage.py
Patch 1612746
M configDialog.py
M NEWS.txt
AM tabbedpages.py
........
r58715 | georg.brandl | 2007-10-30 10:51:18 -0700 (Tue, 30 Oct 2007) | 2 lines
Use correct markup.
........
r58716 | georg.brandl | 2007-10-30 10:57:12 -0700 (Tue, 30 Oct 2007) | 2 lines
Make example about hiding None return values at the prompt clearer.
........
r58728 | neal.norwitz | 2007-10-30 23:33:20 -0700 (Tue, 30 Oct 2007) | 1 line
Fix some compiler warnings for signed comparisons on Unix and Windows.
........
r58731 | martin.v.loewis | 2007-10-31 10:19:33 -0700 (Wed, 31 Oct 2007) | 2 lines
Adding Christian Heimes.
........
r58737 | raymond.hettinger | 2007-10-31 14:57:58 -0700 (Wed, 31 Oct 2007) | 1 line
Clarify the reasons why pickle is almost always better than marshal
........
r58739 | raymond.hettinger | 2007-10-31 15:15:49 -0700 (Wed, 31 Oct 2007) | 1 line
Sets are marshalable.
........
2007-11-01 19:42:39 +00:00
|
|
|
|
2011-10-06 18:57:27 +02:00
|
|
|
if (_PyAccu_Init(&acc))
|
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
|
|
s = PyUnicode_FromString("(");
|
|
|
|
|
if (s == NULL || _PyAccu_Accumulate(&acc, s))
|
|
|
|
|
goto error;
|
|
|
|
|
Py_CLEAR(s);
|
2001-06-16 05:11:17 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
/* Do repr() on each element. */
|
|
|
|
|
for (i = 0; i < n; ++i) {
|
|
|
|
|
if (Py_EnterRecursiveCall(" while getting the repr of a tuple"))
|
2011-10-06 18:57:27 +02:00
|
|
|
goto error;
|
2010-05-09 15:52:27 +00:00
|
|
|
s = PyObject_Repr(v->ob_item[i]);
|
|
|
|
|
Py_LeaveRecursiveCall();
|
2011-10-06 18:57:27 +02:00
|
|
|
if (i > 0 && _PyAccu_Accumulate(&acc, sep))
|
|
|
|
|
goto error;
|
|
|
|
|
if (s == NULL || _PyAccu_Accumulate(&acc, s))
|
|
|
|
|
goto error;
|
|
|
|
|
Py_CLEAR(s);
|
2010-05-09 15:52:27 +00:00
|
|
|
}
|
2011-10-06 18:57:27 +02:00
|
|
|
if (n > 1)
|
|
|
|
|
s = PyUnicode_FromString(")");
|
|
|
|
|
else
|
|
|
|
|
s = PyUnicode_FromString(",)");
|
|
|
|
|
if (s == NULL || _PyAccu_Accumulate(&acc, s))
|
|
|
|
|
goto error;
|
|
|
|
|
Py_CLEAR(s);
|
2001-06-16 05:11:17 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
Py_ReprLeave((PyObject *)v);
|
2011-10-06 18:57:27 +02:00
|
|
|
return _PyAccu_Finish(&acc);
|
|
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
_PyAccu_Destroy(&acc);
|
|
|
|
|
Py_XDECREF(s);
|
|
|
|
|
Py_ReprLeave((PyObject *)v);
|
|
|
|
|
return NULL;
|
1990-10-14 12:07:46 +00:00
|
|
|
}
|
|
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
/* The addend 82520, was selected from the range(0, 1000000) for
|
|
|
|
|
generating the greatest number of prime multipliers for tuples
|
2004-06-04 06:35:20 +00:00
|
|
|
upto length eight:
|
|
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
1082527, 1165049, 1082531, 1165057, 1247581, 1330103, 1082533,
|
2004-06-04 06:35:20 +00:00
|
|
|
1330111, 1412633, 1165069, 1247599, 1495177, 1577699
|
|
|
|
|
*/
|
|
|
|
|
|
2010-10-17 20:54:53 +00:00
|
|
|
static Py_hash_t
|
2000-07-09 07:04:36 +00:00
|
|
|
tuplehash(PyTupleObject *v)
|
1993-03-29 10:43:31 +00:00
|
|
|
{
|
2012-12-10 18:32:53 -08:00
|
|
|
register Py_uhash_t x; /* Unsigned for defined overflow behavior. */
|
2011-09-24 18:18:40 +01:00
|
|
|
register Py_hash_t y;
|
2010-05-09 15:52:27 +00:00
|
|
|
register Py_ssize_t len = Py_SIZE(v);
|
|
|
|
|
register PyObject **p;
|
2012-01-14 15:45:13 -08:00
|
|
|
Py_uhash_t mult = _PyHASH_MULTIPLIER;
|
2012-12-10 18:15:46 -08:00
|
|
|
x = 0x345678UL;
|
2010-05-09 15:52:27 +00:00
|
|
|
p = v->ob_item;
|
|
|
|
|
while (--len >= 0) {
|
|
|
|
|
y = PyObject_Hash(*p++);
|
|
|
|
|
if (y == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
x = (x ^ y) * mult;
|
|
|
|
|
/* the cast might truncate len; that doesn't change hash stability */
|
2012-12-10 18:32:53 -08:00
|
|
|
mult += (Py_hash_t)(82520UL + len + len);
|
2010-05-09 15:52:27 +00:00
|
|
|
}
|
2012-12-10 18:15:46 -08:00
|
|
|
x += 97531UL;
|
2011-09-24 18:18:40 +01:00
|
|
|
if (x == (Py_uhash_t)-1)
|
2010-05-09 15:52:27 +00:00
|
|
|
x = -2;
|
|
|
|
|
return x;
|
1993-03-29 10:43:31 +00:00
|
|
|
}
|
|
|
|
|
|
2006-02-15 17:27:45 +00:00
|
|
|
static Py_ssize_t
|
2000-07-09 07:04:36 +00:00
|
|
|
tuplelength(PyTupleObject *a)
|
1990-10-14 12:07:46 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
return Py_SIZE(a);
|
1990-10-14 12:07:46 +00:00
|
|
|
}
|
|
|
|
|
|
2000-04-27 21:41:03 +00:00
|
|
|
static int
|
2000-07-09 07:04:36 +00:00
|
|
|
tuplecontains(PyTupleObject *a, PyObject *el)
|
2000-04-27 21:41:03 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
Py_ssize_t i;
|
|
|
|
|
int cmp;
|
2000-04-27 21:41:03 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
for (i = 0, cmp = 0 ; cmp == 0 && i < Py_SIZE(a); ++i)
|
|
|
|
|
cmp = PyObject_RichCompareBool(el, PyTuple_GET_ITEM(a, i),
|
|
|
|
|
Py_EQ);
|
|
|
|
|
return cmp;
|
2000-04-27 21:41:03 +00:00
|
|
|
}
|
|
|
|
|
|
1997-05-02 03:12:38 +00:00
|
|
|
static PyObject *
|
2006-02-15 17:27:45 +00:00
|
|
|
tupleitem(register PyTupleObject *a, register Py_ssize_t i)
|
1990-10-14 12:07:46 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
if (i < 0 || i >= Py_SIZE(a)) {
|
|
|
|
|
PyErr_SetString(PyExc_IndexError, "tuple index out of range");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
Py_INCREF(a->ob_item[i]);
|
|
|
|
|
return a->ob_item[i];
|
1990-10-14 12:07:46 +00:00
|
|
|
}
|
|
|
|
|
|
1997-05-02 03:12:38 +00:00
|
|
|
static PyObject *
|
2010-05-09 15:52:27 +00:00
|
|
|
tupleslice(register PyTupleObject *a, register Py_ssize_t ilow,
|
|
|
|
|
register Py_ssize_t ihigh)
|
1990-10-14 12:07:46 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
register PyTupleObject *np;
|
|
|
|
|
PyObject **src, **dest;
|
|
|
|
|
register Py_ssize_t i;
|
|
|
|
|
Py_ssize_t len;
|
|
|
|
|
if (ilow < 0)
|
|
|
|
|
ilow = 0;
|
|
|
|
|
if (ihigh > Py_SIZE(a))
|
|
|
|
|
ihigh = Py_SIZE(a);
|
|
|
|
|
if (ihigh < ilow)
|
|
|
|
|
ihigh = ilow;
|
|
|
|
|
if (ilow == 0 && ihigh == Py_SIZE(a) && PyTuple_CheckExact(a)) {
|
|
|
|
|
Py_INCREF(a);
|
|
|
|
|
return (PyObject *)a;
|
|
|
|
|
}
|
|
|
|
|
len = ihigh - ilow;
|
|
|
|
|
np = (PyTupleObject *)PyTuple_New(len);
|
|
|
|
|
if (np == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
src = a->ob_item + ilow;
|
|
|
|
|
dest = np->ob_item;
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
|
PyObject *v = src[i];
|
|
|
|
|
Py_INCREF(v);
|
|
|
|
|
dest[i] = v;
|
|
|
|
|
}
|
|
|
|
|
return (PyObject *)np;
|
1990-10-14 12:07:46 +00:00
|
|
|
}
|
|
|
|
|
|
1997-05-02 03:12:38 +00:00
|
|
|
PyObject *
|
2006-02-15 17:27:45 +00:00
|
|
|
PyTuple_GetSlice(PyObject *op, Py_ssize_t i, Py_ssize_t j)
|
1992-01-14 18:45:33 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
if (op == NULL || !PyTuple_Check(op)) {
|
|
|
|
|
PyErr_BadInternalCall();
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
return tupleslice((PyTupleObject *)op, i, j);
|
1992-01-14 18:45:33 +00:00
|
|
|
}
|
|
|
|
|
|
1997-05-02 03:12:38 +00:00
|
|
|
static PyObject *
|
2000-07-09 07:04:36 +00:00
|
|
|
tupleconcat(register PyTupleObject *a, register PyObject *bb)
|
1990-10-14 12:07:46 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
register Py_ssize_t size;
|
|
|
|
|
register Py_ssize_t i;
|
|
|
|
|
PyObject **src, **dest;
|
|
|
|
|
PyTupleObject *np;
|
|
|
|
|
if (!PyTuple_Check(bb)) {
|
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
|
"can only concatenate tuple (not \"%.200s\") to tuple",
|
|
|
|
|
Py_TYPE(bb)->tp_name);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
1997-05-02 03:12:38 +00:00
|
|
|
#define b ((PyTupleObject *)bb)
|
2010-05-09 15:52:27 +00:00
|
|
|
size = Py_SIZE(a) + Py_SIZE(b);
|
|
|
|
|
if (size < 0)
|
|
|
|
|
return PyErr_NoMemory();
|
|
|
|
|
np = (PyTupleObject *) PyTuple_New(size);
|
|
|
|
|
if (np == NULL) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
src = a->ob_item;
|
|
|
|
|
dest = np->ob_item;
|
|
|
|
|
for (i = 0; i < Py_SIZE(a); i++) {
|
|
|
|
|
PyObject *v = src[i];
|
|
|
|
|
Py_INCREF(v);
|
|
|
|
|
dest[i] = v;
|
|
|
|
|
}
|
|
|
|
|
src = b->ob_item;
|
|
|
|
|
dest = np->ob_item + Py_SIZE(a);
|
|
|
|
|
for (i = 0; i < Py_SIZE(b); i++) {
|
|
|
|
|
PyObject *v = src[i];
|
|
|
|
|
Py_INCREF(v);
|
|
|
|
|
dest[i] = v;
|
|
|
|
|
}
|
|
|
|
|
return (PyObject *)np;
|
1990-10-14 12:07:46 +00:00
|
|
|
#undef b
|
|
|
|
|
}
|
|
|
|
|
|
1997-05-02 03:12:38 +00:00
|
|
|
static PyObject *
|
2006-02-15 17:27:45 +00:00
|
|
|
tuplerepeat(PyTupleObject *a, Py_ssize_t n)
|
1991-06-04 19:35:24 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
Py_ssize_t i, j;
|
|
|
|
|
Py_ssize_t size;
|
|
|
|
|
PyTupleObject *np;
|
|
|
|
|
PyObject **p, **items;
|
|
|
|
|
if (n < 0)
|
|
|
|
|
n = 0;
|
|
|
|
|
if (Py_SIZE(a) == 0 || n == 1) {
|
|
|
|
|
if (PyTuple_CheckExact(a)) {
|
|
|
|
|
/* Since tuples are immutable, we can return a shared
|
|
|
|
|
copy in this case */
|
|
|
|
|
Py_INCREF(a);
|
|
|
|
|
return (PyObject *)a;
|
|
|
|
|
}
|
|
|
|
|
if (Py_SIZE(a) == 0)
|
|
|
|
|
return PyTuple_New(0);
|
|
|
|
|
}
|
2012-10-06 18:04:49 +01:00
|
|
|
if (n > PY_SSIZE_T_MAX / Py_SIZE(a))
|
2010-05-09 15:52:27 +00:00
|
|
|
return PyErr_NoMemory();
|
2012-10-06 18:04:49 +01:00
|
|
|
size = Py_SIZE(a) * n;
|
2010-05-09 15:52:27 +00:00
|
|
|
np = (PyTupleObject *) PyTuple_New(size);
|
|
|
|
|
if (np == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
p = np->ob_item;
|
|
|
|
|
items = a->ob_item;
|
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
|
for (j = 0; j < Py_SIZE(a); j++) {
|
|
|
|
|
*p = items[j];
|
|
|
|
|
Py_INCREF(*p);
|
|
|
|
|
p++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return (PyObject *) np;
|
1991-06-04 19:35:24 +00:00
|
|
|
}
|
|
|
|
|
|
2008-02-07 00:41:02 +00:00
|
|
|
static PyObject *
|
|
|
|
|
tupleindex(PyTupleObject *self, PyObject *args)
|
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
Py_ssize_t i, start=0, stop=Py_SIZE(self);
|
2011-11-06 21:02:39 +02:00
|
|
|
PyObject *v;
|
2008-02-07 00:41:02 +00:00
|
|
|
|
2011-11-06 21:02:39 +02:00
|
|
|
if (!PyArg_ParseTuple(args, "O|O&O&:index", &v,
|
|
|
|
|
_PyEval_SliceIndex, &start,
|
|
|
|
|
_PyEval_SliceIndex, &stop))
|
2010-05-09 15:52:27 +00:00
|
|
|
return NULL;
|
|
|
|
|
if (start < 0) {
|
|
|
|
|
start += Py_SIZE(self);
|
|
|
|
|
if (start < 0)
|
|
|
|
|
start = 0;
|
|
|
|
|
}
|
|
|
|
|
if (stop < 0) {
|
|
|
|
|
stop += Py_SIZE(self);
|
|
|
|
|
if (stop < 0)
|
|
|
|
|
stop = 0;
|
|
|
|
|
}
|
|
|
|
|
for (i = start; i < stop && i < Py_SIZE(self); i++) {
|
|
|
|
|
int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ);
|
|
|
|
|
if (cmp > 0)
|
|
|
|
|
return PyLong_FromSsize_t(i);
|
|
|
|
|
else if (cmp < 0)
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
PyErr_SetString(PyExc_ValueError, "tuple.index(x): x not in tuple");
|
|
|
|
|
return NULL;
|
2008-02-07 00:41:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
tuplecount(PyTupleObject *self, PyObject *v)
|
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
Py_ssize_t count = 0;
|
|
|
|
|
Py_ssize_t i;
|
2008-02-07 00:41:02 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
for (i = 0; i < Py_SIZE(self); i++) {
|
|
|
|
|
int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ);
|
|
|
|
|
if (cmp > 0)
|
|
|
|
|
count++;
|
|
|
|
|
else if (cmp < 0)
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
return PyLong_FromSsize_t(count);
|
2008-02-07 00:41:02 +00:00
|
|
|
}
|
|
|
|
|
|
2000-06-23 14:18:11 +00:00
|
|
|
static int
|
|
|
|
|
tupletraverse(PyTupleObject *o, visitproc visit, void *arg)
|
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
Py_ssize_t i;
|
2000-06-23 14:18:11 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
for (i = Py_SIZE(o); --i >= 0; )
|
|
|
|
|
Py_VISIT(o->ob_item[i]);
|
|
|
|
|
return 0;
|
2000-06-23 14:18:11 +00:00
|
|
|
}
|
|
|
|
|
|
2001-01-18 00:00:53 +00:00
|
|
|
static PyObject *
|
|
|
|
|
tuplerichcompare(PyObject *v, PyObject *w, int op)
|
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
PyTupleObject *vt, *wt;
|
|
|
|
|
Py_ssize_t i;
|
|
|
|
|
Py_ssize_t vlen, wlen;
|
2001-01-18 00:00:53 +00:00
|
|
|
|
2011-08-10 20:28:54 -05:00
|
|
|
if (!PyTuple_Check(v) || !PyTuple_Check(w))
|
|
|
|
|
Py_RETURN_NOTIMPLEMENTED;
|
2001-01-18 00:00:53 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
vt = (PyTupleObject *)v;
|
|
|
|
|
wt = (PyTupleObject *)w;
|
2001-01-18 00:00:53 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
vlen = Py_SIZE(vt);
|
|
|
|
|
wlen = Py_SIZE(wt);
|
2001-01-18 00:00:53 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
/* Note: the corresponding code for lists has an "early out" test
|
|
|
|
|
* here when op is EQ or NE and the lengths differ. That pays there,
|
|
|
|
|
* but Tim was unable to find any real code where EQ/NE tuple
|
|
|
|
|
* compares don't have the same length, so testing for it here would
|
|
|
|
|
* have cost without benefit.
|
|
|
|
|
*/
|
2001-05-15 20:12:59 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
/* Search for the first index where items are different.
|
|
|
|
|
* Note that because tuples are immutable, it's safe to reuse
|
|
|
|
|
* vlen and wlen across the comparison calls.
|
|
|
|
|
*/
|
|
|
|
|
for (i = 0; i < vlen && i < wlen; i++) {
|
|
|
|
|
int k = PyObject_RichCompareBool(vt->ob_item[i],
|
|
|
|
|
wt->ob_item[i], Py_EQ);
|
|
|
|
|
if (k < 0)
|
|
|
|
|
return NULL;
|
|
|
|
|
if (!k)
|
|
|
|
|
break;
|
|
|
|
|
}
|
2001-01-18 00:00:53 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
if (i >= vlen || i >= wlen) {
|
|
|
|
|
/* No more items to compare -- compare sizes */
|
|
|
|
|
int cmp;
|
|
|
|
|
PyObject *res;
|
|
|
|
|
switch (op) {
|
|
|
|
|
case Py_LT: cmp = vlen < wlen; break;
|
|
|
|
|
case Py_LE: cmp = vlen <= wlen; break;
|
|
|
|
|
case Py_EQ: cmp = vlen == wlen; break;
|
|
|
|
|
case Py_NE: cmp = vlen != wlen; break;
|
|
|
|
|
case Py_GT: cmp = vlen > wlen; break;
|
|
|
|
|
case Py_GE: cmp = vlen >= wlen; break;
|
|
|
|
|
default: return NULL; /* cannot happen */
|
|
|
|
|
}
|
|
|
|
|
if (cmp)
|
|
|
|
|
res = Py_True;
|
|
|
|
|
else
|
|
|
|
|
res = Py_False;
|
|
|
|
|
Py_INCREF(res);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
2001-01-18 00:00:53 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
/* We have an item that differs -- shortcuts for EQ/NE */
|
|
|
|
|
if (op == Py_EQ) {
|
|
|
|
|
Py_INCREF(Py_False);
|
|
|
|
|
return Py_False;
|
|
|
|
|
}
|
|
|
|
|
if (op == Py_NE) {
|
|
|
|
|
Py_INCREF(Py_True);
|
|
|
|
|
return Py_True;
|
|
|
|
|
}
|
2001-01-18 00:00:53 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
/* Compare the final item again using the proper operator */
|
|
|
|
|
return PyObject_RichCompare(vt->ob_item[i], wt->ob_item[i], op);
|
2001-01-18 00:00:53 +00:00
|
|
|
}
|
|
|
|
|
|
2002-07-17 16:30:39 +00:00
|
|
|
static PyObject *
|
2001-08-30 03:11:59 +00:00
|
|
|
tuple_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
|
|
|
|
|
|
2001-08-02 04:15:00 +00:00
|
|
|
static PyObject *
|
|
|
|
|
tuple_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
PyObject *arg = NULL;
|
|
|
|
|
static char *kwlist[] = {"sequence", 0};
|
2001-08-02 04:15:00 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
if (type != &PyTuple_Type)
|
|
|
|
|
return tuple_subtype_new(type, args, kwds);
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:tuple", kwlist, &arg))
|
|
|
|
|
return NULL;
|
2001-08-02 04:15:00 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
if (arg == NULL)
|
|
|
|
|
return PyTuple_New(0);
|
|
|
|
|
else
|
|
|
|
|
return PySequence_Tuple(arg);
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
2001-08-30 03:11:59 +00:00
|
|
|
static PyObject *
|
|
|
|
|
tuple_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
PyObject *tmp, *newobj, *item;
|
|
|
|
|
Py_ssize_t i, n;
|
2001-08-30 03:11:59 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
assert(PyType_IsSubtype(type, &PyTuple_Type));
|
|
|
|
|
tmp = tuple_new(&PyTuple_Type, args, kwds);
|
|
|
|
|
if (tmp == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
assert(PyTuple_Check(tmp));
|
|
|
|
|
newobj = type->tp_alloc(type, n = PyTuple_GET_SIZE(tmp));
|
|
|
|
|
if (newobj == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
|
item = PyTuple_GET_ITEM(tmp, i);
|
|
|
|
|
Py_INCREF(item);
|
|
|
|
|
PyTuple_SET_ITEM(newobj, i, item);
|
|
|
|
|
}
|
|
|
|
|
Py_DECREF(tmp);
|
|
|
|
|
return newobj;
|
2001-08-30 03:11:59 +00:00
|
|
|
}
|
|
|
|
|
|
2002-06-13 20:33:02 +00:00
|
|
|
PyDoc_STRVAR(tuple_doc,
|
2010-03-01 04:08:34 +00:00
|
|
|
"tuple() -> empty tuple\n\
|
|
|
|
|
tuple(iterable) -> tuple initialized from iterable's items\n\
|
|
|
|
|
\n\
|
|
|
|
|
If the argument is a tuple, the return value is the same object.");
|
2001-08-02 04:15:00 +00:00
|
|
|
|
1997-05-02 03:12:38 +00:00
|
|
|
static PySequenceMethods tuple_as_sequence = {
|
2010-05-09 15:52:27 +00:00
|
|
|
(lenfunc)tuplelength, /* sq_length */
|
|
|
|
|
(binaryfunc)tupleconcat, /* sq_concat */
|
|
|
|
|
(ssizeargfunc)tuplerepeat, /* sq_repeat */
|
|
|
|
|
(ssizeargfunc)tupleitem, /* sq_item */
|
|
|
|
|
0, /* sq_slice */
|
|
|
|
|
0, /* sq_ass_item */
|
|
|
|
|
0, /* sq_ass_slice */
|
|
|
|
|
(objobjproc)tuplecontains, /* sq_contains */
|
1990-10-14 12:07:46 +00:00
|
|
|
};
|
|
|
|
|
|
2002-06-11 10:55:12 +00:00
|
|
|
static PyObject*
|
|
|
|
|
tuplesubscript(PyTupleObject* self, PyObject* item)
|
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
if (PyIndex_Check(item)) {
|
|
|
|
|
Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
|
|
|
|
|
if (i == -1 && PyErr_Occurred())
|
|
|
|
|
return NULL;
|
|
|
|
|
if (i < 0)
|
|
|
|
|
i += PyTuple_GET_SIZE(self);
|
|
|
|
|
return tupleitem(self, i);
|
|
|
|
|
}
|
|
|
|
|
else if (PySlice_Check(item)) {
|
|
|
|
|
Py_ssize_t start, stop, step, slicelength, cur, i;
|
|
|
|
|
PyObject* result;
|
|
|
|
|
PyObject* it;
|
|
|
|
|
PyObject **src, **dest;
|
2002-06-11 10:55:12 +00:00
|
|
|
|
2010-12-03 20:14:31 +00:00
|
|
|
if (PySlice_GetIndicesEx(item,
|
2010-05-09 15:52:27 +00:00
|
|
|
PyTuple_GET_SIZE(self),
|
|
|
|
|
&start, &stop, &step, &slicelength) < 0) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2002-06-11 10:55:12 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
if (slicelength <= 0) {
|
|
|
|
|
return PyTuple_New(0);
|
|
|
|
|
}
|
|
|
|
|
else if (start == 0 && step == 1 &&
|
|
|
|
|
slicelength == PyTuple_GET_SIZE(self) &&
|
|
|
|
|
PyTuple_CheckExact(self)) {
|
|
|
|
|
Py_INCREF(self);
|
|
|
|
|
return (PyObject *)self;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
result = PyTuple_New(slicelength);
|
|
|
|
|
if (!result) return NULL;
|
2002-06-11 10:55:12 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
src = self->ob_item;
|
|
|
|
|
dest = ((PyTupleObject *)result)->ob_item;
|
|
|
|
|
for (cur = start, i = 0; i < slicelength;
|
|
|
|
|
cur += step, i++) {
|
|
|
|
|
it = src[cur];
|
|
|
|
|
Py_INCREF(it);
|
|
|
|
|
dest[i] = it;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
|
"tuple indices must be integers, not %.200s",
|
|
|
|
|
Py_TYPE(item)->tp_name);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2002-06-11 10:55:12 +00:00
|
|
|
}
|
|
|
|
|
|
2003-01-29 17:58:45 +00:00
|
|
|
static PyObject *
|
|
|
|
|
tuple_getnewargs(PyTupleObject *v)
|
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
return Py_BuildValue("(N)", tupleslice(v, 0, Py_SIZE(v)));
|
|
|
|
|
|
2003-01-29 17:58:45 +00:00
|
|
|
}
|
|
|
|
|
|
Merged revisions 64119,64147,64150,64165,64219-64221,64229-64230,64233,64235,64253,64278,64280,64301,64303,64320,64328,64338-64339 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r64119 | andrew.kuchling | 2008-06-11 14:53:14 +0200 (mer., 11 juin 2008) | 1 line
Note PEP 371 section
........
r64147 | benjamin.peterson | 2008-06-11 22:04:30 +0200 (mer., 11 juin 2008) | 2 lines
update ACKS and NEWs for multiprocessing
........
r64150 | georg.brandl | 2008-06-11 22:28:06 +0200 (mer., 11 juin 2008) | 2 lines
Can we agree to put dots at entry ends? Thanks.
........
r64165 | armin.rigo | 2008-06-12 11:50:58 +0200 (jeu., 12 juin 2008) | 3 lines
Sounds obvious, but I didn't even realize that you can put non-string
keys in type dictionaries without using this locals() hack.
........
r64219 | neal.norwitz | 2008-06-13 08:00:46 +0200 (ven., 13 juin 2008) | 1 line
Check for memory alloc failure
........
r64220 | neal.norwitz | 2008-06-13 08:02:26 +0200 (ven., 13 juin 2008) | 3 lines
Fix some memory dealloc problems when exceptions occur.
It caused: "Fatal Python error: UNREF invalid object" in the DoubleTest.
........
r64221 | neal.norwitz | 2008-06-13 08:03:25 +0200 (ven., 13 juin 2008) | 3 lines
Fix typo in method name. The LT class implemented less than. The LE class
should implement less than or equal to (as the code does).
........
r64229 | georg.brandl | 2008-06-13 15:26:54 +0200 (ven., 13 juin 2008) | 2 lines
Clarification.
........
r64230 | robert.schuppenies | 2008-06-13 15:29:37 +0200 (ven., 13 juin 2008) | 2 lines
Fixed: sys.getsizeof does not take the actual length of the tuples into account.
........
r64233 | benjamin.peterson | 2008-06-13 17:11:50 +0200 (ven., 13 juin 2008) | 2 lines
platform.uname now tries to fill empty values even when os.uname is present
........
r64235 | benjamin.peterson | 2008-06-13 17:41:09 +0200 (ven., 13 juin 2008) | 1 line
set svn:ignore on multiprocessing
........
r64253 | andrew.kuchling | 2008-06-13 21:38:18 +0200 (ven., 13 juin 2008) | 1 line
Typo fixes
........
r64278 | martin.v.loewis | 2008-06-14 16:24:47 +0200 (sam., 14 juin 2008) | 2 lines
Disable UAC by default.
........
r64280 | gregory.p.smith | 2008-06-14 19:34:09 +0200 (sam., 14 juin 2008) | 3 lines
silence the test when it is skipped on some platforms. should fix a
buildbot.
........
r64301 | georg.brandl | 2008-06-15 21:54:36 +0200 (dim., 15 juin 2008) | 2 lines
Forward-port new test from r64300.
........
r64303 | raymond.hettinger | 2008-06-16 03:42:40 +0200 (lun., 16 juin 2008) | 1 line
Issue 3116: fix quadratic behavior in marshal.dumps().
........
r64320 | georg.brandl | 2008-06-16 23:00:47 +0200 (lun., 16 juin 2008) | 2 lines
Add Jesse Noller to the developers list.
........
r64328 | georg.brandl | 2008-06-17 11:01:35 +0200 (mar., 17 juin 2008) | 2 lines
Split the HTML index.
........
r64338 | vinay.sajip | 2008-06-17 13:02:14 +0200 (mar., 17 juin 2008) | 1 line
Bug #3126: StreamHandler and FileHandler check before calling "flush" and "close" that the stream object has these, using hasattr (thanks to bobf for the patch).
........
r64339 | vinay.sajip | 2008-06-17 13:04:02 +0200 (mar., 17 juin 2008) | 1 line
Updated with fix for #3126.
........
2008-06-17 21:11:29 +00:00
|
|
|
static PyObject *
|
|
|
|
|
tuple_sizeof(PyTupleObject *self)
|
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
Py_ssize_t res;
|
Merged revisions 64119,64147,64150,64165,64219-64221,64229-64230,64233,64235,64253,64278,64280,64301,64303,64320,64328,64338-64339 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r64119 | andrew.kuchling | 2008-06-11 14:53:14 +0200 (mer., 11 juin 2008) | 1 line
Note PEP 371 section
........
r64147 | benjamin.peterson | 2008-06-11 22:04:30 +0200 (mer., 11 juin 2008) | 2 lines
update ACKS and NEWs for multiprocessing
........
r64150 | georg.brandl | 2008-06-11 22:28:06 +0200 (mer., 11 juin 2008) | 2 lines
Can we agree to put dots at entry ends? Thanks.
........
r64165 | armin.rigo | 2008-06-12 11:50:58 +0200 (jeu., 12 juin 2008) | 3 lines
Sounds obvious, but I didn't even realize that you can put non-string
keys in type dictionaries without using this locals() hack.
........
r64219 | neal.norwitz | 2008-06-13 08:00:46 +0200 (ven., 13 juin 2008) | 1 line
Check for memory alloc failure
........
r64220 | neal.norwitz | 2008-06-13 08:02:26 +0200 (ven., 13 juin 2008) | 3 lines
Fix some memory dealloc problems when exceptions occur.
It caused: "Fatal Python error: UNREF invalid object" in the DoubleTest.
........
r64221 | neal.norwitz | 2008-06-13 08:03:25 +0200 (ven., 13 juin 2008) | 3 lines
Fix typo in method name. The LT class implemented less than. The LE class
should implement less than or equal to (as the code does).
........
r64229 | georg.brandl | 2008-06-13 15:26:54 +0200 (ven., 13 juin 2008) | 2 lines
Clarification.
........
r64230 | robert.schuppenies | 2008-06-13 15:29:37 +0200 (ven., 13 juin 2008) | 2 lines
Fixed: sys.getsizeof does not take the actual length of the tuples into account.
........
r64233 | benjamin.peterson | 2008-06-13 17:11:50 +0200 (ven., 13 juin 2008) | 2 lines
platform.uname now tries to fill empty values even when os.uname is present
........
r64235 | benjamin.peterson | 2008-06-13 17:41:09 +0200 (ven., 13 juin 2008) | 1 line
set svn:ignore on multiprocessing
........
r64253 | andrew.kuchling | 2008-06-13 21:38:18 +0200 (ven., 13 juin 2008) | 1 line
Typo fixes
........
r64278 | martin.v.loewis | 2008-06-14 16:24:47 +0200 (sam., 14 juin 2008) | 2 lines
Disable UAC by default.
........
r64280 | gregory.p.smith | 2008-06-14 19:34:09 +0200 (sam., 14 juin 2008) | 3 lines
silence the test when it is skipped on some platforms. should fix a
buildbot.
........
r64301 | georg.brandl | 2008-06-15 21:54:36 +0200 (dim., 15 juin 2008) | 2 lines
Forward-port new test from r64300.
........
r64303 | raymond.hettinger | 2008-06-16 03:42:40 +0200 (lun., 16 juin 2008) | 1 line
Issue 3116: fix quadratic behavior in marshal.dumps().
........
r64320 | georg.brandl | 2008-06-16 23:00:47 +0200 (lun., 16 juin 2008) | 2 lines
Add Jesse Noller to the developers list.
........
r64328 | georg.brandl | 2008-06-17 11:01:35 +0200 (mar., 17 juin 2008) | 2 lines
Split the HTML index.
........
r64338 | vinay.sajip | 2008-06-17 13:02:14 +0200 (mar., 17 juin 2008) | 1 line
Bug #3126: StreamHandler and FileHandler check before calling "flush" and "close" that the stream object has these, using hasattr (thanks to bobf for the patch).
........
r64339 | vinay.sajip | 2008-06-17 13:04:02 +0200 (mar., 17 juin 2008) | 1 line
Updated with fix for #3126.
........
2008-06-17 21:11:29 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
res = PyTuple_Type.tp_basicsize + Py_SIZE(self) * sizeof(PyObject *);
|
|
|
|
|
return PyLong_FromSsize_t(res);
|
Merged revisions 64119,64147,64150,64165,64219-64221,64229-64230,64233,64235,64253,64278,64280,64301,64303,64320,64328,64338-64339 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r64119 | andrew.kuchling | 2008-06-11 14:53:14 +0200 (mer., 11 juin 2008) | 1 line
Note PEP 371 section
........
r64147 | benjamin.peterson | 2008-06-11 22:04:30 +0200 (mer., 11 juin 2008) | 2 lines
update ACKS and NEWs for multiprocessing
........
r64150 | georg.brandl | 2008-06-11 22:28:06 +0200 (mer., 11 juin 2008) | 2 lines
Can we agree to put dots at entry ends? Thanks.
........
r64165 | armin.rigo | 2008-06-12 11:50:58 +0200 (jeu., 12 juin 2008) | 3 lines
Sounds obvious, but I didn't even realize that you can put non-string
keys in type dictionaries without using this locals() hack.
........
r64219 | neal.norwitz | 2008-06-13 08:00:46 +0200 (ven., 13 juin 2008) | 1 line
Check for memory alloc failure
........
r64220 | neal.norwitz | 2008-06-13 08:02:26 +0200 (ven., 13 juin 2008) | 3 lines
Fix some memory dealloc problems when exceptions occur.
It caused: "Fatal Python error: UNREF invalid object" in the DoubleTest.
........
r64221 | neal.norwitz | 2008-06-13 08:03:25 +0200 (ven., 13 juin 2008) | 3 lines
Fix typo in method name. The LT class implemented less than. The LE class
should implement less than or equal to (as the code does).
........
r64229 | georg.brandl | 2008-06-13 15:26:54 +0200 (ven., 13 juin 2008) | 2 lines
Clarification.
........
r64230 | robert.schuppenies | 2008-06-13 15:29:37 +0200 (ven., 13 juin 2008) | 2 lines
Fixed: sys.getsizeof does not take the actual length of the tuples into account.
........
r64233 | benjamin.peterson | 2008-06-13 17:11:50 +0200 (ven., 13 juin 2008) | 2 lines
platform.uname now tries to fill empty values even when os.uname is present
........
r64235 | benjamin.peterson | 2008-06-13 17:41:09 +0200 (ven., 13 juin 2008) | 1 line
set svn:ignore on multiprocessing
........
r64253 | andrew.kuchling | 2008-06-13 21:38:18 +0200 (ven., 13 juin 2008) | 1 line
Typo fixes
........
r64278 | martin.v.loewis | 2008-06-14 16:24:47 +0200 (sam., 14 juin 2008) | 2 lines
Disable UAC by default.
........
r64280 | gregory.p.smith | 2008-06-14 19:34:09 +0200 (sam., 14 juin 2008) | 3 lines
silence the test when it is skipped on some platforms. should fix a
buildbot.
........
r64301 | georg.brandl | 2008-06-15 21:54:36 +0200 (dim., 15 juin 2008) | 2 lines
Forward-port new test from r64300.
........
r64303 | raymond.hettinger | 2008-06-16 03:42:40 +0200 (lun., 16 juin 2008) | 1 line
Issue 3116: fix quadratic behavior in marshal.dumps().
........
r64320 | georg.brandl | 2008-06-16 23:00:47 +0200 (lun., 16 juin 2008) | 2 lines
Add Jesse Noller to the developers list.
........
r64328 | georg.brandl | 2008-06-17 11:01:35 +0200 (mar., 17 juin 2008) | 2 lines
Split the HTML index.
........
r64338 | vinay.sajip | 2008-06-17 13:02:14 +0200 (mar., 17 juin 2008) | 1 line
Bug #3126: StreamHandler and FileHandler check before calling "flush" and "close" that the stream object has these, using hasattr (thanks to bobf for the patch).
........
r64339 | vinay.sajip | 2008-06-17 13:04:02 +0200 (mar., 17 juin 2008) | 1 line
Updated with fix for #3126.
........
2008-06-17 21:11:29 +00:00
|
|
|
}
|
|
|
|
|
|
2008-02-07 00:41:02 +00:00
|
|
|
PyDoc_STRVAR(index_doc,
|
2008-10-11 00:49:57 +00:00
|
|
|
"T.index(value, [start, [stop]]) -> integer -- return first index of value.\n"
|
|
|
|
|
"Raises ValueError if the value is not present."
|
|
|
|
|
);
|
2008-02-07 00:41:02 +00:00
|
|
|
PyDoc_STRVAR(count_doc,
|
|
|
|
|
"T.count(value) -> integer -- return number of occurrences of value");
|
Merged revisions 64119,64147,64150,64165,64219-64221,64229-64230,64233,64235,64253,64278,64280,64301,64303,64320,64328,64338-64339 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r64119 | andrew.kuchling | 2008-06-11 14:53:14 +0200 (mer., 11 juin 2008) | 1 line
Note PEP 371 section
........
r64147 | benjamin.peterson | 2008-06-11 22:04:30 +0200 (mer., 11 juin 2008) | 2 lines
update ACKS and NEWs for multiprocessing
........
r64150 | georg.brandl | 2008-06-11 22:28:06 +0200 (mer., 11 juin 2008) | 2 lines
Can we agree to put dots at entry ends? Thanks.
........
r64165 | armin.rigo | 2008-06-12 11:50:58 +0200 (jeu., 12 juin 2008) | 3 lines
Sounds obvious, but I didn't even realize that you can put non-string
keys in type dictionaries without using this locals() hack.
........
r64219 | neal.norwitz | 2008-06-13 08:00:46 +0200 (ven., 13 juin 2008) | 1 line
Check for memory alloc failure
........
r64220 | neal.norwitz | 2008-06-13 08:02:26 +0200 (ven., 13 juin 2008) | 3 lines
Fix some memory dealloc problems when exceptions occur.
It caused: "Fatal Python error: UNREF invalid object" in the DoubleTest.
........
r64221 | neal.norwitz | 2008-06-13 08:03:25 +0200 (ven., 13 juin 2008) | 3 lines
Fix typo in method name. The LT class implemented less than. The LE class
should implement less than or equal to (as the code does).
........
r64229 | georg.brandl | 2008-06-13 15:26:54 +0200 (ven., 13 juin 2008) | 2 lines
Clarification.
........
r64230 | robert.schuppenies | 2008-06-13 15:29:37 +0200 (ven., 13 juin 2008) | 2 lines
Fixed: sys.getsizeof does not take the actual length of the tuples into account.
........
r64233 | benjamin.peterson | 2008-06-13 17:11:50 +0200 (ven., 13 juin 2008) | 2 lines
platform.uname now tries to fill empty values even when os.uname is present
........
r64235 | benjamin.peterson | 2008-06-13 17:41:09 +0200 (ven., 13 juin 2008) | 1 line
set svn:ignore on multiprocessing
........
r64253 | andrew.kuchling | 2008-06-13 21:38:18 +0200 (ven., 13 juin 2008) | 1 line
Typo fixes
........
r64278 | martin.v.loewis | 2008-06-14 16:24:47 +0200 (sam., 14 juin 2008) | 2 lines
Disable UAC by default.
........
r64280 | gregory.p.smith | 2008-06-14 19:34:09 +0200 (sam., 14 juin 2008) | 3 lines
silence the test when it is skipped on some platforms. should fix a
buildbot.
........
r64301 | georg.brandl | 2008-06-15 21:54:36 +0200 (dim., 15 juin 2008) | 2 lines
Forward-port new test from r64300.
........
r64303 | raymond.hettinger | 2008-06-16 03:42:40 +0200 (lun., 16 juin 2008) | 1 line
Issue 3116: fix quadratic behavior in marshal.dumps().
........
r64320 | georg.brandl | 2008-06-16 23:00:47 +0200 (lun., 16 juin 2008) | 2 lines
Add Jesse Noller to the developers list.
........
r64328 | georg.brandl | 2008-06-17 11:01:35 +0200 (mar., 17 juin 2008) | 2 lines
Split the HTML index.
........
r64338 | vinay.sajip | 2008-06-17 13:02:14 +0200 (mar., 17 juin 2008) | 1 line
Bug #3126: StreamHandler and FileHandler check before calling "flush" and "close" that the stream object has these, using hasattr (thanks to bobf for the patch).
........
r64339 | vinay.sajip | 2008-06-17 13:04:02 +0200 (mar., 17 juin 2008) | 1 line
Updated with fix for #3126.
........
2008-06-17 21:11:29 +00:00
|
|
|
PyDoc_STRVAR(sizeof_doc,
|
|
|
|
|
"T.__sizeof__() -- size of T in memory, in bytes");
|
2008-02-07 00:41:02 +00:00
|
|
|
|
2003-01-29 17:58:45 +00:00
|
|
|
static PyMethodDef tuple_methods[] = {
|
2010-05-09 15:52:27 +00:00
|
|
|
{"__getnewargs__", (PyCFunction)tuple_getnewargs, METH_NOARGS},
|
|
|
|
|
{"__sizeof__", (PyCFunction)tuple_sizeof, METH_NOARGS, sizeof_doc},
|
|
|
|
|
{"index", (PyCFunction)tupleindex, METH_VARARGS, index_doc},
|
|
|
|
|
{"count", (PyCFunction)tuplecount, METH_O, count_doc},
|
|
|
|
|
{NULL, NULL} /* sentinel */
|
2003-01-29 17:58:45 +00:00
|
|
|
};
|
|
|
|
|
|
2002-06-11 10:55:12 +00:00
|
|
|
static PyMappingMethods tuple_as_mapping = {
|
2010-05-09 15:52:27 +00:00
|
|
|
(lenfunc)tuplelength,
|
|
|
|
|
(binaryfunc)tuplesubscript,
|
|
|
|
|
0
|
2002-06-11 10:55:12 +00:00
|
|
|
};
|
|
|
|
|
|
2002-08-09 01:30:17 +00:00
|
|
|
static PyObject *tuple_iter(PyObject *seq);
|
|
|
|
|
|
1997-05-02 03:12:38 +00:00
|
|
|
PyTypeObject PyTuple_Type = {
|
2010-05-09 15:52:27 +00:00
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
|
|
|
|
"tuple",
|
|
|
|
|
sizeof(PyTupleObject) - sizeof(PyObject *),
|
|
|
|
|
sizeof(PyObject *),
|
|
|
|
|
(destructor)tupledealloc, /* tp_dealloc */
|
|
|
|
|
0, /* tp_print */
|
|
|
|
|
0, /* tp_getattr */
|
|
|
|
|
0, /* tp_setattr */
|
|
|
|
|
0, /* tp_reserved */
|
|
|
|
|
(reprfunc)tuplerepr, /* tp_repr */
|
|
|
|
|
0, /* tp_as_number */
|
|
|
|
|
&tuple_as_sequence, /* tp_as_sequence */
|
|
|
|
|
&tuple_as_mapping, /* tp_as_mapping */
|
|
|
|
|
(hashfunc)tuplehash, /* tp_hash */
|
|
|
|
|
0, /* tp_call */
|
|
|
|
|
0, /* tp_str */
|
|
|
|
|
PyObject_GenericGetAttr, /* tp_getattro */
|
|
|
|
|
0, /* tp_setattro */
|
|
|
|
|
0, /* tp_as_buffer */
|
|
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
|
|
|
|
|
Py_TPFLAGS_BASETYPE | Py_TPFLAGS_TUPLE_SUBCLASS, /* tp_flags */
|
|
|
|
|
tuple_doc, /* tp_doc */
|
|
|
|
|
(traverseproc)tupletraverse, /* tp_traverse */
|
|
|
|
|
0, /* tp_clear */
|
|
|
|
|
tuplerichcompare, /* tp_richcompare */
|
|
|
|
|
0, /* tp_weaklistoffset */
|
|
|
|
|
tuple_iter, /* tp_iter */
|
|
|
|
|
0, /* tp_iternext */
|
|
|
|
|
tuple_methods, /* tp_methods */
|
|
|
|
|
0, /* tp_members */
|
|
|
|
|
0, /* tp_getset */
|
|
|
|
|
0, /* tp_base */
|
|
|
|
|
0, /* tp_dict */
|
|
|
|
|
0, /* tp_descr_get */
|
|
|
|
|
0, /* tp_descr_set */
|
|
|
|
|
0, /* tp_dictoffset */
|
|
|
|
|
0, /* tp_init */
|
|
|
|
|
0, /* tp_alloc */
|
|
|
|
|
tuple_new, /* tp_new */
|
|
|
|
|
PyObject_GC_Del, /* tp_free */
|
1990-10-14 12:07:46 +00:00
|
|
|
};
|
1993-10-26 17:58:25 +00:00
|
|
|
|
|
|
|
|
/* The following function breaks the notion that tuples are immutable:
|
|
|
|
|
it changes the size of a tuple. We get away with this only if there
|
|
|
|
|
is only one module referencing the object. You can also think of it
|
2000-10-05 19:36:49 +00:00
|
|
|
as creating a new tuple object and destroying the old one, only more
|
|
|
|
|
efficiently. In any case, don't use this if the tuple may already be
|
2001-05-28 22:30:08 +00:00
|
|
|
known to some other part of the code. */
|
1993-10-26 17:58:25 +00:00
|
|
|
|
|
|
|
|
int
|
2006-02-15 17:27:45 +00:00
|
|
|
_PyTuple_Resize(PyObject **pv, Py_ssize_t newsize)
|
1993-10-26 17:58:25 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
register PyTupleObject *v;
|
|
|
|
|
register PyTupleObject *sv;
|
|
|
|
|
Py_ssize_t i;
|
|
|
|
|
Py_ssize_t oldsize;
|
1993-11-01 13:46:50 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
v = (PyTupleObject *) *pv;
|
|
|
|
|
if (v == NULL || Py_TYPE(v) != &PyTuple_Type ||
|
|
|
|
|
(Py_SIZE(v) != 0 && Py_REFCNT(v) != 1)) {
|
|
|
|
|
*pv = 0;
|
|
|
|
|
Py_XDECREF(v);
|
|
|
|
|
PyErr_BadInternalCall();
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
oldsize = Py_SIZE(v);
|
|
|
|
|
if (oldsize == newsize)
|
|
|
|
|
return 0;
|
2000-10-05 19:36:49 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
if (oldsize == 0) {
|
|
|
|
|
/* Empty tuples are often shared, so we should never
|
|
|
|
|
resize them in-place even if we do own the only
|
|
|
|
|
(current) reference */
|
|
|
|
|
Py_DECREF(v);
|
|
|
|
|
*pv = PyTuple_New(newsize);
|
|
|
|
|
return *pv == NULL ? -1 : 0;
|
|
|
|
|
}
|
2001-05-28 13:11:02 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
/* XXX UNREF/NEWREF interface should be more symmetrical */
|
|
|
|
|
_Py_DEC_REFTOTAL;
|
|
|
|
|
if (_PyObject_GC_IS_TRACKED(v))
|
|
|
|
|
_PyObject_GC_UNTRACK(v);
|
|
|
|
|
_Py_ForgetReference((PyObject *) v);
|
|
|
|
|
/* DECREF items deleted by shrinkage */
|
|
|
|
|
for (i = newsize; i < oldsize; i++) {
|
2014-02-09 13:33:53 +02:00
|
|
|
Py_CLEAR(v->ob_item[i]);
|
2010-05-09 15:52:27 +00:00
|
|
|
}
|
|
|
|
|
sv = PyObject_GC_Resize(PyTupleObject, v, newsize);
|
|
|
|
|
if (sv == NULL) {
|
|
|
|
|
*pv = NULL;
|
|
|
|
|
PyObject_GC_Del(v);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
_Py_NewReference((PyObject *) sv);
|
|
|
|
|
/* Zero out items added by growing */
|
|
|
|
|
if (newsize > oldsize)
|
|
|
|
|
memset(&sv->ob_item[oldsize], 0,
|
|
|
|
|
sizeof(*sv->ob_item) * (newsize - oldsize));
|
|
|
|
|
*pv = (PyObject *) sv;
|
|
|
|
|
_PyObject_GC_TRACK(sv);
|
|
|
|
|
return 0;
|
1993-10-26 17:58:25 +00:00
|
|
|
}
|
1997-08-05 02:16:08 +00:00
|
|
|
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60790 | raymond.hettinger | 2008-02-14 10:32:45 +0100 (Thu, 14 Feb 2008) | 4 lines
Add diagnostic message to help figure-out why SocketServer tests occasionally crash
when trying to remove a pid that in not in the activechildren list.
........
r60791 | raymond.hettinger | 2008-02-14 11:46:57 +0100 (Thu, 14 Feb 2008) | 1 line
Add fixed-point examples to the decimal FAQ
........
r60792 | raymond.hettinger | 2008-02-14 12:01:10 +0100 (Thu, 14 Feb 2008) | 1 line
Improve rst markup
........
r60794 | raymond.hettinger | 2008-02-14 12:57:25 +0100 (Thu, 14 Feb 2008) | 1 line
Show how to remove exponents.
........
r60795 | raymond.hettinger | 2008-02-14 13:05:42 +0100 (Thu, 14 Feb 2008) | 1 line
Fix markup.
........
r60797 | christian.heimes | 2008-02-14 13:47:33 +0100 (Thu, 14 Feb 2008) | 1 line
Implemented Martin's suggestion to clear the free lists during the garbage collection of the highest generation.
........
r60798 | raymond.hettinger | 2008-02-14 13:49:37 +0100 (Thu, 14 Feb 2008) | 1 line
Simplify moneyfmt() recipe.
........
r60810 | raymond.hettinger | 2008-02-14 20:02:39 +0100 (Thu, 14 Feb 2008) | 1 line
Fix markup
........
r60811 | raymond.hettinger | 2008-02-14 20:30:30 +0100 (Thu, 14 Feb 2008) | 1 line
No need to register subclass of ABCs.
........
r60814 | thomas.heller | 2008-02-14 22:00:28 +0100 (Thu, 14 Feb 2008) | 1 line
Try to correct a markup error that does hide the following paragraph.
........
r60822 | christian.heimes | 2008-02-14 23:40:11 +0100 (Thu, 14 Feb 2008) | 1 line
Use a static and interned string for __subclasscheck__ and __instancecheck__ as suggested by Thomas Heller in #2115
........
r60827 | christian.heimes | 2008-02-15 07:57:08 +0100 (Fri, 15 Feb 2008) | 1 line
Fixed repr() and str() of complex numbers. Complex suffered from the same problem as floats but I forgot to test and fix them.
........
r60830 | christian.heimes | 2008-02-15 09:20:11 +0100 (Fri, 15 Feb 2008) | 2 lines
Bug #2111: mmap segfaults when trying to write a block opened with PROT_READ
Thanks to Thomas Herve for the fix.
........
r60835 | eric.smith | 2008-02-15 13:14:32 +0100 (Fri, 15 Feb 2008) | 1 line
In PyNumber_ToBase, changed from an assert to returning an error when PyObject_Index() returns something other than an int or long. It should never be possible to trigger this, as PyObject_Index checks to make sure it returns an int or long.
........
r60837 | skip.montanaro | 2008-02-15 20:03:59 +0100 (Fri, 15 Feb 2008) | 8 lines
Two new functions:
* place_summary_first copies the regrtest summary to the front of the file
making it easier to scan quickly for problems.
* count_failures gets the actual count of the number of failing tests, not
just a 1 (some failures) or 0 (no failures).
........
r60840 | raymond.hettinger | 2008-02-15 22:21:25 +0100 (Fri, 15 Feb 2008) | 1 line
Update example to match the current syntax.
........
r60841 | amaury.forgeotdarc | 2008-02-15 22:22:45 +0100 (Fri, 15 Feb 2008) | 8 lines
Issue #2115: __slot__ attributes setting was 10x slower.
Also correct a possible crash using ABCs.
This change is exactly the same as an optimisation
done 5 years ago, but on slot *access*:
http://svn.python.org/view?view=rev&rev=28297
........
r60842 | amaury.forgeotdarc | 2008-02-15 22:27:44 +0100 (Fri, 15 Feb 2008) | 2 lines
Temporarily let these tests pass
........
r60843 | kurt.kaiser | 2008-02-15 22:56:36 +0100 (Fri, 15 Feb 2008) | 2 lines
ScriptBinding event handlers weren't returning 'break'. Patch 2050, Tal Einat.
........
r60844 | kurt.kaiser | 2008-02-15 23:25:09 +0100 (Fri, 15 Feb 2008) | 4 lines
Configured selection highlighting colors were ignored; updating highlighting
in the config dialog would cause non-Python files to be colored as if they
were Python source; improve use of ColorDelagator. Patch 1334. Tal Einat.
........
r60845 | amaury.forgeotdarc | 2008-02-15 23:44:20 +0100 (Fri, 15 Feb 2008) | 9 lines
Re-enable tests, they were failing since gc.collect() clears the various freelists.
They still remain fragile.
For example, a call to assertEqual currently does not make any allocation
(which surprised me at first).
But this can change when gc.collect also deletes the numerous "zombie frames"
attached to each function.
........
2008-02-16 07:38:31 +00:00
|
|
|
int
|
|
|
|
|
PyTuple_ClearFreeList(void)
|
1997-08-05 02:16:08 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
int freelist_size = 0;
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60568 | christian.heimes | 2008-02-04 19:48:38 +0100 (Mon, 04 Feb 2008) | 1 line
Increase debugging to investige failing tests on some build bots
........
r60570 | christian.heimes | 2008-02-04 20:30:05 +0100 (Mon, 04 Feb 2008) | 1 line
Small adjustments for test compact freelist test. It's no passing on Windows as well.
........
r60573 | amaury.forgeotdarc | 2008-02-04 21:53:14 +0100 (Mon, 04 Feb 2008) | 2 lines
Correct quotes in NEWS file
........
r60575 | amaury.forgeotdarc | 2008-02-04 22:45:05 +0100 (Mon, 04 Feb 2008) | 13 lines
#1750076: Debugger did not step on every iteration of a while statement.
The mapping between bytecode offsets and source lines (lnotab) did not contain
an entry for the beginning of the loop.
Now it does, and the lnotab can be a bit larger:
in particular, several statements on the same line generate several entries.
However, this does not bother the settrace function, which will trigger only
one 'line' event.
The lnotab seems to be exactly the same as with python2.4.
........
r60584 | amaury.forgeotdarc | 2008-02-05 01:26:21 +0100 (Tue, 05 Feb 2008) | 3 lines
Change r60575 broke test_compile:
there is no need to emit co_lnotab item when both offsets are zeros.
........
r60587 | skip.montanaro | 2008-02-05 03:32:16 +0100 (Tue, 05 Feb 2008) | 1 line
sync with most recent version from python-mode sf project
........
r60588 | lars.gustaebel | 2008-02-05 12:51:40 +0100 (Tue, 05 Feb 2008) | 5 lines
Issue #2004: Use mode 0700 for temporary directories and default
permissions for missing directories.
(will backport to 2.5)
........
r60590 | georg.brandl | 2008-02-05 13:01:24 +0100 (Tue, 05 Feb 2008) | 2 lines
Convert external links to internal links. Fixes #2010.
........
r60592 | marc-andre.lemburg | 2008-02-05 15:50:40 +0100 (Tue, 05 Feb 2008) | 3 lines
Keep distutils Python 2.1 compatible (or even Python 2.4 in this case).
........
r60593 | andrew.kuchling | 2008-02-05 17:06:57 +0100 (Tue, 05 Feb 2008) | 5 lines
Update PEP URL.
(This code is duplicated between pydoc and DocXMLRPCServer; maybe it
should be refactored as a GHOP project.)
2.5.2 backport candidate.
........
r60596 | guido.van.rossum | 2008-02-05 18:32:15 +0100 (Tue, 05 Feb 2008) | 2 lines
In the experimental 'Scanner' feature, the group count was set wrong.
........
r60602 | facundo.batista | 2008-02-05 20:03:32 +0100 (Tue, 05 Feb 2008) | 3 lines
Issue 1951. Converts wave test cases to unittest.
........
r60603 | georg.brandl | 2008-02-05 20:07:10 +0100 (Tue, 05 Feb 2008) | 2 lines
Actually run the test.
........
r60604 | skip.montanaro | 2008-02-05 20:24:30 +0100 (Tue, 05 Feb 2008) | 2 lines
correct object name
........
r60605 | georg.brandl | 2008-02-05 20:58:17 +0100 (Tue, 05 Feb 2008) | 7 lines
* Use the same code to profile for test_profile and test_cprofile.
* Convert both to unittest.
* Use the same unit testing code.
* Include the expected output in both test files.
* Make it possible to regenerate the expected output by running
the file as a script with an '-r' argument.
........
r60613 | raymond.hettinger | 2008-02-06 02:49:00 +0100 (Wed, 06 Feb 2008) | 1 line
Sync-up with Py3k work.
........
r60614 | christian.heimes | 2008-02-06 13:44:34 +0100 (Wed, 06 Feb 2008) | 1 line
Limit free list of method and builtin function objects to 256 entries each.
........
r60616 | christian.heimes | 2008-02-06 14:33:44 +0100 (Wed, 06 Feb 2008) | 7 lines
Unified naming convention for free lists and their limits. All free lists
in Object/ are named ``free_list``, the counter ``numfree`` and the upper
limit is a macro ``PyName_MAXFREELIST`` inside an #ifndef block.
The chances should make it easier to adjust Python for platforms with
less memory, e.g. mobile phones.
........
2008-02-06 14:31:34 +00:00
|
|
|
#if PyTuple_MAXSAVESIZE > 0
|
2010-05-09 15:52:27 +00:00
|
|
|
int i;
|
|
|
|
|
for (i = 1; i < PyTuple_MAXSAVESIZE; i++) {
|
|
|
|
|
PyTupleObject *p, *q;
|
|
|
|
|
p = free_list[i];
|
|
|
|
|
freelist_size += numfree[i];
|
|
|
|
|
free_list[i] = NULL;
|
|
|
|
|
numfree[i] = 0;
|
|
|
|
|
while (p) {
|
|
|
|
|
q = p;
|
|
|
|
|
p = (PyTupleObject *)(p->ob_item[0]);
|
|
|
|
|
PyObject_GC_Del(q);
|
|
|
|
|
}
|
|
|
|
|
}
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60790 | raymond.hettinger | 2008-02-14 10:32:45 +0100 (Thu, 14 Feb 2008) | 4 lines
Add diagnostic message to help figure-out why SocketServer tests occasionally crash
when trying to remove a pid that in not in the activechildren list.
........
r60791 | raymond.hettinger | 2008-02-14 11:46:57 +0100 (Thu, 14 Feb 2008) | 1 line
Add fixed-point examples to the decimal FAQ
........
r60792 | raymond.hettinger | 2008-02-14 12:01:10 +0100 (Thu, 14 Feb 2008) | 1 line
Improve rst markup
........
r60794 | raymond.hettinger | 2008-02-14 12:57:25 +0100 (Thu, 14 Feb 2008) | 1 line
Show how to remove exponents.
........
r60795 | raymond.hettinger | 2008-02-14 13:05:42 +0100 (Thu, 14 Feb 2008) | 1 line
Fix markup.
........
r60797 | christian.heimes | 2008-02-14 13:47:33 +0100 (Thu, 14 Feb 2008) | 1 line
Implemented Martin's suggestion to clear the free lists during the garbage collection of the highest generation.
........
r60798 | raymond.hettinger | 2008-02-14 13:49:37 +0100 (Thu, 14 Feb 2008) | 1 line
Simplify moneyfmt() recipe.
........
r60810 | raymond.hettinger | 2008-02-14 20:02:39 +0100 (Thu, 14 Feb 2008) | 1 line
Fix markup
........
r60811 | raymond.hettinger | 2008-02-14 20:30:30 +0100 (Thu, 14 Feb 2008) | 1 line
No need to register subclass of ABCs.
........
r60814 | thomas.heller | 2008-02-14 22:00:28 +0100 (Thu, 14 Feb 2008) | 1 line
Try to correct a markup error that does hide the following paragraph.
........
r60822 | christian.heimes | 2008-02-14 23:40:11 +0100 (Thu, 14 Feb 2008) | 1 line
Use a static and interned string for __subclasscheck__ and __instancecheck__ as suggested by Thomas Heller in #2115
........
r60827 | christian.heimes | 2008-02-15 07:57:08 +0100 (Fri, 15 Feb 2008) | 1 line
Fixed repr() and str() of complex numbers. Complex suffered from the same problem as floats but I forgot to test and fix them.
........
r60830 | christian.heimes | 2008-02-15 09:20:11 +0100 (Fri, 15 Feb 2008) | 2 lines
Bug #2111: mmap segfaults when trying to write a block opened with PROT_READ
Thanks to Thomas Herve for the fix.
........
r60835 | eric.smith | 2008-02-15 13:14:32 +0100 (Fri, 15 Feb 2008) | 1 line
In PyNumber_ToBase, changed from an assert to returning an error when PyObject_Index() returns something other than an int or long. It should never be possible to trigger this, as PyObject_Index checks to make sure it returns an int or long.
........
r60837 | skip.montanaro | 2008-02-15 20:03:59 +0100 (Fri, 15 Feb 2008) | 8 lines
Two new functions:
* place_summary_first copies the regrtest summary to the front of the file
making it easier to scan quickly for problems.
* count_failures gets the actual count of the number of failing tests, not
just a 1 (some failures) or 0 (no failures).
........
r60840 | raymond.hettinger | 2008-02-15 22:21:25 +0100 (Fri, 15 Feb 2008) | 1 line
Update example to match the current syntax.
........
r60841 | amaury.forgeotdarc | 2008-02-15 22:22:45 +0100 (Fri, 15 Feb 2008) | 8 lines
Issue #2115: __slot__ attributes setting was 10x slower.
Also correct a possible crash using ABCs.
This change is exactly the same as an optimisation
done 5 years ago, but on slot *access*:
http://svn.python.org/view?view=rev&rev=28297
........
r60842 | amaury.forgeotdarc | 2008-02-15 22:27:44 +0100 (Fri, 15 Feb 2008) | 2 lines
Temporarily let these tests pass
........
r60843 | kurt.kaiser | 2008-02-15 22:56:36 +0100 (Fri, 15 Feb 2008) | 2 lines
ScriptBinding event handlers weren't returning 'break'. Patch 2050, Tal Einat.
........
r60844 | kurt.kaiser | 2008-02-15 23:25:09 +0100 (Fri, 15 Feb 2008) | 4 lines
Configured selection highlighting colors were ignored; updating highlighting
in the config dialog would cause non-Python files to be colored as if they
were Python source; improve use of ColorDelagator. Patch 1334. Tal Einat.
........
r60845 | amaury.forgeotdarc | 2008-02-15 23:44:20 +0100 (Fri, 15 Feb 2008) | 9 lines
Re-enable tests, they were failing since gc.collect() clears the various freelists.
They still remain fragile.
For example, a call to assertEqual currently does not make any allocation
(which surprised me at first).
But this can change when gc.collect also deletes the numerous "zombie frames"
attached to each function.
........
2008-02-16 07:38:31 +00:00
|
|
|
#endif
|
2010-05-09 15:52:27 +00:00
|
|
|
return freelist_size;
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60790 | raymond.hettinger | 2008-02-14 10:32:45 +0100 (Thu, 14 Feb 2008) | 4 lines
Add diagnostic message to help figure-out why SocketServer tests occasionally crash
when trying to remove a pid that in not in the activechildren list.
........
r60791 | raymond.hettinger | 2008-02-14 11:46:57 +0100 (Thu, 14 Feb 2008) | 1 line
Add fixed-point examples to the decimal FAQ
........
r60792 | raymond.hettinger | 2008-02-14 12:01:10 +0100 (Thu, 14 Feb 2008) | 1 line
Improve rst markup
........
r60794 | raymond.hettinger | 2008-02-14 12:57:25 +0100 (Thu, 14 Feb 2008) | 1 line
Show how to remove exponents.
........
r60795 | raymond.hettinger | 2008-02-14 13:05:42 +0100 (Thu, 14 Feb 2008) | 1 line
Fix markup.
........
r60797 | christian.heimes | 2008-02-14 13:47:33 +0100 (Thu, 14 Feb 2008) | 1 line
Implemented Martin's suggestion to clear the free lists during the garbage collection of the highest generation.
........
r60798 | raymond.hettinger | 2008-02-14 13:49:37 +0100 (Thu, 14 Feb 2008) | 1 line
Simplify moneyfmt() recipe.
........
r60810 | raymond.hettinger | 2008-02-14 20:02:39 +0100 (Thu, 14 Feb 2008) | 1 line
Fix markup
........
r60811 | raymond.hettinger | 2008-02-14 20:30:30 +0100 (Thu, 14 Feb 2008) | 1 line
No need to register subclass of ABCs.
........
r60814 | thomas.heller | 2008-02-14 22:00:28 +0100 (Thu, 14 Feb 2008) | 1 line
Try to correct a markup error that does hide the following paragraph.
........
r60822 | christian.heimes | 2008-02-14 23:40:11 +0100 (Thu, 14 Feb 2008) | 1 line
Use a static and interned string for __subclasscheck__ and __instancecheck__ as suggested by Thomas Heller in #2115
........
r60827 | christian.heimes | 2008-02-15 07:57:08 +0100 (Fri, 15 Feb 2008) | 1 line
Fixed repr() and str() of complex numbers. Complex suffered from the same problem as floats but I forgot to test and fix them.
........
r60830 | christian.heimes | 2008-02-15 09:20:11 +0100 (Fri, 15 Feb 2008) | 2 lines
Bug #2111: mmap segfaults when trying to write a block opened with PROT_READ
Thanks to Thomas Herve for the fix.
........
r60835 | eric.smith | 2008-02-15 13:14:32 +0100 (Fri, 15 Feb 2008) | 1 line
In PyNumber_ToBase, changed from an assert to returning an error when PyObject_Index() returns something other than an int or long. It should never be possible to trigger this, as PyObject_Index checks to make sure it returns an int or long.
........
r60837 | skip.montanaro | 2008-02-15 20:03:59 +0100 (Fri, 15 Feb 2008) | 8 lines
Two new functions:
* place_summary_first copies the regrtest summary to the front of the file
making it easier to scan quickly for problems.
* count_failures gets the actual count of the number of failing tests, not
just a 1 (some failures) or 0 (no failures).
........
r60840 | raymond.hettinger | 2008-02-15 22:21:25 +0100 (Fri, 15 Feb 2008) | 1 line
Update example to match the current syntax.
........
r60841 | amaury.forgeotdarc | 2008-02-15 22:22:45 +0100 (Fri, 15 Feb 2008) | 8 lines
Issue #2115: __slot__ attributes setting was 10x slower.
Also correct a possible crash using ABCs.
This change is exactly the same as an optimisation
done 5 years ago, but on slot *access*:
http://svn.python.org/view?view=rev&rev=28297
........
r60842 | amaury.forgeotdarc | 2008-02-15 22:27:44 +0100 (Fri, 15 Feb 2008) | 2 lines
Temporarily let these tests pass
........
r60843 | kurt.kaiser | 2008-02-15 22:56:36 +0100 (Fri, 15 Feb 2008) | 2 lines
ScriptBinding event handlers weren't returning 'break'. Patch 2050, Tal Einat.
........
r60844 | kurt.kaiser | 2008-02-15 23:25:09 +0100 (Fri, 15 Feb 2008) | 4 lines
Configured selection highlighting colors were ignored; updating highlighting
in the config dialog would cause non-Python files to be colored as if they
were Python source; improve use of ColorDelagator. Patch 1334. Tal Einat.
........
r60845 | amaury.forgeotdarc | 2008-02-15 23:44:20 +0100 (Fri, 15 Feb 2008) | 9 lines
Re-enable tests, they were failing since gc.collect() clears the various freelists.
They still remain fragile.
For example, a call to assertEqual currently does not make any allocation
(which surprised me at first).
But this can change when gc.collect also deletes the numerous "zombie frames"
attached to each function.
........
2008-02-16 07:38:31 +00:00
|
|
|
}
|
2010-05-09 15:52:27 +00:00
|
|
|
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60790 | raymond.hettinger | 2008-02-14 10:32:45 +0100 (Thu, 14 Feb 2008) | 4 lines
Add diagnostic message to help figure-out why SocketServer tests occasionally crash
when trying to remove a pid that in not in the activechildren list.
........
r60791 | raymond.hettinger | 2008-02-14 11:46:57 +0100 (Thu, 14 Feb 2008) | 1 line
Add fixed-point examples to the decimal FAQ
........
r60792 | raymond.hettinger | 2008-02-14 12:01:10 +0100 (Thu, 14 Feb 2008) | 1 line
Improve rst markup
........
r60794 | raymond.hettinger | 2008-02-14 12:57:25 +0100 (Thu, 14 Feb 2008) | 1 line
Show how to remove exponents.
........
r60795 | raymond.hettinger | 2008-02-14 13:05:42 +0100 (Thu, 14 Feb 2008) | 1 line
Fix markup.
........
r60797 | christian.heimes | 2008-02-14 13:47:33 +0100 (Thu, 14 Feb 2008) | 1 line
Implemented Martin's suggestion to clear the free lists during the garbage collection of the highest generation.
........
r60798 | raymond.hettinger | 2008-02-14 13:49:37 +0100 (Thu, 14 Feb 2008) | 1 line
Simplify moneyfmt() recipe.
........
r60810 | raymond.hettinger | 2008-02-14 20:02:39 +0100 (Thu, 14 Feb 2008) | 1 line
Fix markup
........
r60811 | raymond.hettinger | 2008-02-14 20:30:30 +0100 (Thu, 14 Feb 2008) | 1 line
No need to register subclass of ABCs.
........
r60814 | thomas.heller | 2008-02-14 22:00:28 +0100 (Thu, 14 Feb 2008) | 1 line
Try to correct a markup error that does hide the following paragraph.
........
r60822 | christian.heimes | 2008-02-14 23:40:11 +0100 (Thu, 14 Feb 2008) | 1 line
Use a static and interned string for __subclasscheck__ and __instancecheck__ as suggested by Thomas Heller in #2115
........
r60827 | christian.heimes | 2008-02-15 07:57:08 +0100 (Fri, 15 Feb 2008) | 1 line
Fixed repr() and str() of complex numbers. Complex suffered from the same problem as floats but I forgot to test and fix them.
........
r60830 | christian.heimes | 2008-02-15 09:20:11 +0100 (Fri, 15 Feb 2008) | 2 lines
Bug #2111: mmap segfaults when trying to write a block opened with PROT_READ
Thanks to Thomas Herve for the fix.
........
r60835 | eric.smith | 2008-02-15 13:14:32 +0100 (Fri, 15 Feb 2008) | 1 line
In PyNumber_ToBase, changed from an assert to returning an error when PyObject_Index() returns something other than an int or long. It should never be possible to trigger this, as PyObject_Index checks to make sure it returns an int or long.
........
r60837 | skip.montanaro | 2008-02-15 20:03:59 +0100 (Fri, 15 Feb 2008) | 8 lines
Two new functions:
* place_summary_first copies the regrtest summary to the front of the file
making it easier to scan quickly for problems.
* count_failures gets the actual count of the number of failing tests, not
just a 1 (some failures) or 0 (no failures).
........
r60840 | raymond.hettinger | 2008-02-15 22:21:25 +0100 (Fri, 15 Feb 2008) | 1 line
Update example to match the current syntax.
........
r60841 | amaury.forgeotdarc | 2008-02-15 22:22:45 +0100 (Fri, 15 Feb 2008) | 8 lines
Issue #2115: __slot__ attributes setting was 10x slower.
Also correct a possible crash using ABCs.
This change is exactly the same as an optimisation
done 5 years ago, but on slot *access*:
http://svn.python.org/view?view=rev&rev=28297
........
r60842 | amaury.forgeotdarc | 2008-02-15 22:27:44 +0100 (Fri, 15 Feb 2008) | 2 lines
Temporarily let these tests pass
........
r60843 | kurt.kaiser | 2008-02-15 22:56:36 +0100 (Fri, 15 Feb 2008) | 2 lines
ScriptBinding event handlers weren't returning 'break'. Patch 2050, Tal Einat.
........
r60844 | kurt.kaiser | 2008-02-15 23:25:09 +0100 (Fri, 15 Feb 2008) | 4 lines
Configured selection highlighting colors were ignored; updating highlighting
in the config dialog would cause non-Python files to be colored as if they
were Python source; improve use of ColorDelagator. Patch 1334. Tal Einat.
........
r60845 | amaury.forgeotdarc | 2008-02-15 23:44:20 +0100 (Fri, 15 Feb 2008) | 9 lines
Re-enable tests, they were failing since gc.collect() clears the various freelists.
They still remain fragile.
For example, a call to assertEqual currently does not make any allocation
(which surprised me at first).
But this can change when gc.collect also deletes the numerous "zombie frames"
attached to each function.
........
2008-02-16 07:38:31 +00:00
|
|
|
void
|
|
|
|
|
PyTuple_Fini(void)
|
|
|
|
|
{
|
|
|
|
|
#if PyTuple_MAXSAVESIZE > 0
|
2010-05-09 15:52:27 +00:00
|
|
|
/* empty tuples are used all over the place and applications may
|
|
|
|
|
* rely on the fact that an empty tuple is a singleton. */
|
2014-02-09 13:33:53 +02:00
|
|
|
Py_CLEAR(free_list[0]);
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60790 | raymond.hettinger | 2008-02-14 10:32:45 +0100 (Thu, 14 Feb 2008) | 4 lines
Add diagnostic message to help figure-out why SocketServer tests occasionally crash
when trying to remove a pid that in not in the activechildren list.
........
r60791 | raymond.hettinger | 2008-02-14 11:46:57 +0100 (Thu, 14 Feb 2008) | 1 line
Add fixed-point examples to the decimal FAQ
........
r60792 | raymond.hettinger | 2008-02-14 12:01:10 +0100 (Thu, 14 Feb 2008) | 1 line
Improve rst markup
........
r60794 | raymond.hettinger | 2008-02-14 12:57:25 +0100 (Thu, 14 Feb 2008) | 1 line
Show how to remove exponents.
........
r60795 | raymond.hettinger | 2008-02-14 13:05:42 +0100 (Thu, 14 Feb 2008) | 1 line
Fix markup.
........
r60797 | christian.heimes | 2008-02-14 13:47:33 +0100 (Thu, 14 Feb 2008) | 1 line
Implemented Martin's suggestion to clear the free lists during the garbage collection of the highest generation.
........
r60798 | raymond.hettinger | 2008-02-14 13:49:37 +0100 (Thu, 14 Feb 2008) | 1 line
Simplify moneyfmt() recipe.
........
r60810 | raymond.hettinger | 2008-02-14 20:02:39 +0100 (Thu, 14 Feb 2008) | 1 line
Fix markup
........
r60811 | raymond.hettinger | 2008-02-14 20:30:30 +0100 (Thu, 14 Feb 2008) | 1 line
No need to register subclass of ABCs.
........
r60814 | thomas.heller | 2008-02-14 22:00:28 +0100 (Thu, 14 Feb 2008) | 1 line
Try to correct a markup error that does hide the following paragraph.
........
r60822 | christian.heimes | 2008-02-14 23:40:11 +0100 (Thu, 14 Feb 2008) | 1 line
Use a static and interned string for __subclasscheck__ and __instancecheck__ as suggested by Thomas Heller in #2115
........
r60827 | christian.heimes | 2008-02-15 07:57:08 +0100 (Fri, 15 Feb 2008) | 1 line
Fixed repr() and str() of complex numbers. Complex suffered from the same problem as floats but I forgot to test and fix them.
........
r60830 | christian.heimes | 2008-02-15 09:20:11 +0100 (Fri, 15 Feb 2008) | 2 lines
Bug #2111: mmap segfaults when trying to write a block opened with PROT_READ
Thanks to Thomas Herve for the fix.
........
r60835 | eric.smith | 2008-02-15 13:14:32 +0100 (Fri, 15 Feb 2008) | 1 line
In PyNumber_ToBase, changed from an assert to returning an error when PyObject_Index() returns something other than an int or long. It should never be possible to trigger this, as PyObject_Index checks to make sure it returns an int or long.
........
r60837 | skip.montanaro | 2008-02-15 20:03:59 +0100 (Fri, 15 Feb 2008) | 8 lines
Two new functions:
* place_summary_first copies the regrtest summary to the front of the file
making it easier to scan quickly for problems.
* count_failures gets the actual count of the number of failing tests, not
just a 1 (some failures) or 0 (no failures).
........
r60840 | raymond.hettinger | 2008-02-15 22:21:25 +0100 (Fri, 15 Feb 2008) | 1 line
Update example to match the current syntax.
........
r60841 | amaury.forgeotdarc | 2008-02-15 22:22:45 +0100 (Fri, 15 Feb 2008) | 8 lines
Issue #2115: __slot__ attributes setting was 10x slower.
Also correct a possible crash using ABCs.
This change is exactly the same as an optimisation
done 5 years ago, but on slot *access*:
http://svn.python.org/view?view=rev&rev=28297
........
r60842 | amaury.forgeotdarc | 2008-02-15 22:27:44 +0100 (Fri, 15 Feb 2008) | 2 lines
Temporarily let these tests pass
........
r60843 | kurt.kaiser | 2008-02-15 22:56:36 +0100 (Fri, 15 Feb 2008) | 2 lines
ScriptBinding event handlers weren't returning 'break'. Patch 2050, Tal Einat.
........
r60844 | kurt.kaiser | 2008-02-15 23:25:09 +0100 (Fri, 15 Feb 2008) | 4 lines
Configured selection highlighting colors were ignored; updating highlighting
in the config dialog would cause non-Python files to be colored as if they
were Python source; improve use of ColorDelagator. Patch 1334. Tal Einat.
........
r60845 | amaury.forgeotdarc | 2008-02-15 23:44:20 +0100 (Fri, 15 Feb 2008) | 9 lines
Re-enable tests, they were failing since gc.collect() clears the various freelists.
They still remain fragile.
For example, a call to assertEqual currently does not make any allocation
(which surprised me at first).
But this can change when gc.collect also deletes the numerous "zombie frames"
attached to each function.
........
2008-02-16 07:38:31 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
(void)PyTuple_ClearFreeList();
|
1997-08-05 02:16:08 +00:00
|
|
|
#endif
|
2009-03-23 18:52:06 +00:00
|
|
|
#ifdef SHOW_TRACK_COUNT
|
2010-05-09 15:52:27 +00:00
|
|
|
show_track();
|
2009-03-23 18:52:06 +00:00
|
|
|
#endif
|
1997-08-05 02:16:08 +00:00
|
|
|
}
|
2002-08-09 01:30:17 +00:00
|
|
|
|
|
|
|
|
/*********************** Tuple Iterator **************************/
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2010-05-09 15:52:27 +00:00
|
|
|
PyObject_HEAD
|
|
|
|
|
long it_index;
|
|
|
|
|
PyTupleObject *it_seq; /* Set to NULL when iterator is exhausted */
|
2002-08-09 01:30:17 +00:00
|
|
|
} tupleiterobject;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tupleiter_dealloc(tupleiterobject *it)
|
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
_PyObject_GC_UNTRACK(it);
|
|
|
|
|
Py_XDECREF(it->it_seq);
|
|
|
|
|
PyObject_GC_Del(it);
|
2002-08-09 01:30:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
tupleiter_traverse(tupleiterobject *it, visitproc visit, void *arg)
|
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
Py_VISIT(it->it_seq);
|
|
|
|
|
return 0;
|
2002-08-09 01:30:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
tupleiter_next(tupleiterobject *it)
|
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
PyTupleObject *seq;
|
|
|
|
|
PyObject *item;
|
2002-08-09 01:30:17 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
assert(it != NULL);
|
|
|
|
|
seq = it->it_seq;
|
|
|
|
|
if (seq == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
assert(PyTuple_Check(seq));
|
2002-08-09 01:30:17 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
if (it->it_index < PyTuple_GET_SIZE(seq)) {
|
|
|
|
|
item = PyTuple_GET_ITEM(seq, it->it_index);
|
|
|
|
|
++it->it_index;
|
|
|
|
|
Py_INCREF(item);
|
|
|
|
|
return item;
|
|
|
|
|
}
|
2002-08-09 01:30:17 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
Py_DECREF(seq);
|
|
|
|
|
it->it_seq = NULL;
|
|
|
|
|
return NULL;
|
2002-08-09 01:30:17 +00:00
|
|
|
}
|
|
|
|
|
|
2005-09-24 21:23:05 +00:00
|
|
|
static PyObject *
|
2004-03-18 22:43:10 +00:00
|
|
|
tupleiter_len(tupleiterobject *it)
|
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
Py_ssize_t len = 0;
|
|
|
|
|
if (it->it_seq)
|
|
|
|
|
len = PyTuple_GET_SIZE(it->it_seq) - it->it_index;
|
|
|
|
|
return PyLong_FromSsize_t(len);
|
2004-03-18 22:43:10 +00:00
|
|
|
}
|
|
|
|
|
|
2006-02-11 21:32:43 +00:00
|
|
|
PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it)).");
|
2005-09-24 21:23:05 +00:00
|
|
|
|
2012-04-03 10:49:41 +00:00
|
|
|
static PyObject *
|
|
|
|
|
tupleiter_reduce(tupleiterobject *it)
|
|
|
|
|
{
|
|
|
|
|
if (it->it_seq)
|
2012-04-05 00:04:20 +02:00
|
|
|
return Py_BuildValue("N(O)l", _PyObject_GetBuiltin("iter"),
|
2012-04-03 10:49:41 +00:00
|
|
|
it->it_seq, it->it_index);
|
|
|
|
|
else
|
2012-04-05 00:04:20 +02:00
|
|
|
return Py_BuildValue("N(())", _PyObject_GetBuiltin("iter"));
|
2012-04-03 10:49:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
tupleiter_setstate(tupleiterobject *it, PyObject *state)
|
|
|
|
|
{
|
|
|
|
|
long index = PyLong_AsLong(state);
|
|
|
|
|
if (index == -1 && PyErr_Occurred())
|
|
|
|
|
return NULL;
|
|
|
|
|
if (it->it_seq != NULL) {
|
|
|
|
|
if (index < 0)
|
|
|
|
|
index = 0;
|
2014-03-05 13:47:57 +00:00
|
|
|
else if (index > PyTuple_GET_SIZE(it->it_seq))
|
|
|
|
|
index = PyTuple_GET_SIZE(it->it_seq); /* exhausted iterator */
|
2012-04-03 10:49:41 +00:00
|
|
|
it->it_index = index;
|
|
|
|
|
}
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PyDoc_STRVAR(reduce_doc, "Return state information for pickling.");
|
|
|
|
|
PyDoc_STRVAR(setstate_doc, "Set state information for unpickling.");
|
|
|
|
|
|
2005-09-24 21:23:05 +00:00
|
|
|
static PyMethodDef tupleiter_methods[] = {
|
2010-05-09 15:52:27 +00:00
|
|
|
{"__length_hint__", (PyCFunction)tupleiter_len, METH_NOARGS, length_hint_doc},
|
2012-04-03 10:49:41 +00:00
|
|
|
{"__reduce__", (PyCFunction)tupleiter_reduce, METH_NOARGS, reduce_doc},
|
|
|
|
|
{"__setstate__", (PyCFunction)tupleiter_setstate, METH_O, setstate_doc},
|
2010-05-09 15:52:27 +00:00
|
|
|
{NULL, NULL} /* sentinel */
|
2004-03-18 22:43:10 +00:00
|
|
|
};
|
|
|
|
|
|
2002-08-09 01:30:17 +00:00
|
|
|
PyTypeObject PyTupleIter_Type = {
|
2010-05-09 15:52:27 +00:00
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
|
|
|
|
"tuple_iterator", /* tp_name */
|
|
|
|
|
sizeof(tupleiterobject), /* tp_basicsize */
|
|
|
|
|
0, /* tp_itemsize */
|
|
|
|
|
/* methods */
|
|
|
|
|
(destructor)tupleiter_dealloc, /* tp_dealloc */
|
|
|
|
|
0, /* tp_print */
|
|
|
|
|
0, /* tp_getattr */
|
|
|
|
|
0, /* tp_setattr */
|
|
|
|
|
0, /* tp_reserved */
|
|
|
|
|
0, /* tp_repr */
|
|
|
|
|
0, /* tp_as_number */
|
|
|
|
|
0, /* tp_as_sequence */
|
|
|
|
|
0, /* tp_as_mapping */
|
|
|
|
|
0, /* tp_hash */
|
|
|
|
|
0, /* tp_call */
|
|
|
|
|
0, /* tp_str */
|
|
|
|
|
PyObject_GenericGetAttr, /* tp_getattro */
|
|
|
|
|
0, /* tp_setattro */
|
|
|
|
|
0, /* tp_as_buffer */
|
|
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
|
|
|
|
|
0, /* tp_doc */
|
|
|
|
|
(traverseproc)tupleiter_traverse, /* tp_traverse */
|
|
|
|
|
0, /* tp_clear */
|
|
|
|
|
0, /* tp_richcompare */
|
|
|
|
|
0, /* tp_weaklistoffset */
|
|
|
|
|
PyObject_SelfIter, /* tp_iter */
|
|
|
|
|
(iternextfunc)tupleiter_next, /* tp_iternext */
|
|
|
|
|
tupleiter_methods, /* tp_methods */
|
|
|
|
|
0,
|
2002-08-09 01:30:17 +00:00
|
|
|
};
|
2006-04-21 10:40:58 +00:00
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
tuple_iter(PyObject *seq)
|
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
tupleiterobject *it;
|
2006-04-21 10:40:58 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
if (!PyTuple_Check(seq)) {
|
|
|
|
|
PyErr_BadInternalCall();
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
it = PyObject_GC_New(tupleiterobject, &PyTupleIter_Type);
|
|
|
|
|
if (it == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
it->it_index = 0;
|
|
|
|
|
Py_INCREF(seq);
|
|
|
|
|
it->it_seq = (PyTupleObject *)seq;
|
|
|
|
|
_PyObject_GC_TRACK(it);
|
|
|
|
|
return (PyObject *)it;
|
2006-04-21 10:40:58 +00:00
|
|
|
}
|