Commit Graph

3004 Commits

Author SHA1 Message Date
Amaury Forgeot d'Arc 3571fbfed7 Issue #3751: str.rpartition would perform a left-partition when called with
a unicode argument.

will backport.
2008-09-01 19:52:00 +00:00
Antoine Pitrou d4ae97bc38 #3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
exception afterwards (for a subsequent parameter), the user code will
not call PyBuffer_Release() and memory will leak.

Reviewed by Amaury Forgeot d'Arc.
2008-08-29 18:39:48 +00:00
Antoine Pitrou 0668c62677 Issue #2534: speed up isinstance() and issubclass() by 50-70%, so as to
match Python 2.5 speed despite the __instancecheck__ / __subclasscheck__
mechanism. In the process, fix a bug where isinstance() and issubclass(),
when given a tuple of classes as second argument, were looking up
__instancecheck__ / __subclasscheck__ on the tuple rather than on each
type object.

Reviewed by Benjamin Peterson and Raymond Hettinger.
2008-08-26 22:42:08 +00:00
Benjamin Peterson 712ee92309 generate py3k warnings on __getslice__, __delslice__, and __setslice__
Reviewer: Brett Cannon
2008-08-24 18:10:20 +00:00
Neal Norwitz 18aa388ca0 Fix:
* crashes on memory allocation failure found with failmalloc
 * memory leaks found with valgrind
 * compiler warnings in opt mode which would lead to invalid memory reads
 * problem using wrong name in decimal module reported by pychecker

Update the valgrind suppressions file with new leaks that are small/one-time
leaks we don't care about (ie, they are too hard to fix).

TBR=barry
TESTED=./python -E -tt ./Lib/test/regrtest.py -uall (both debug and opt modes)
  in opt mode:
  valgrind -q --leak-check=yes --suppressions=Misc/valgrind-python.supp \
    ./python -E -tt ./Lib/test/regrtest.py -uall,-bsddb,-compiler \
                        -x test_logging test_ssl test_multiprocessing
  valgrind -q --leak-check=yes --suppressions=Misc/valgrind-python.supp \
    ./python -E -tt ./Lib/test/regrtest.py test_multiprocessing
  for i in `seq 1 4000` ; do
    LD_PRELOAD=~/local/lib/libfailmalloc.so FAILMALLOC_INTERVAL=$i \
        ./python -c pass
  done

At least some of these fixes should probably be backported to 2.5.
2008-08-24 05:04:52 +00:00
Christian Heimes 7d4c3177d5 Silenced compiler warning
Objects/stringlib/find.h:97: warning: 'stringlib_contains_obj' defined but not used
Reviewed by Benjamin Peterson
2008-08-22 19:47:25 +00:00
Christian Heimes fb1813cb8d Changed type of numarenas from uint to size_t to silence a GCC warning on 64bit OSes. Reviewed by Benjamin Peterson. 2008-08-22 19:34:15 +00:00
Mark Dickinson 5c2bb1a7d4 issue 3633: Solaris allows fullwidth Unicode digits in isxdigit, so
rewrite float.fromhex to only allow ASCII hex digits on all platforms.
(Tests for this are already present, but the test_float failures
on Solaris hadn't been noticed before.)

Reviewed by Antoine Pitrou.
2008-08-21 21:38:38 +00:00
Eric Smith e5bdccc77b Backport of r63826.
Optimization of str.format() for cases with str, unicode, int, long,
and float arguments.  This gives about 30% speed improvement for the
simplest (but most common) cases.  This patch skips the __format__
dispatch, and also avoids creating an object to hold the format_spec.

Unfortunately there's a complication in 2.6 with int, long, and float
because they always expect str format_specs.  So in the unicode
version of this optimization, just check for unicode objects.  int,
float, long, and str can be added later, if needed.
2008-08-18 14:27:38 +00:00
Amaury Forgeot d'Arc 313bda12e8 Fix a refleak in bytearray.split and bytearray.rsplit, detected by
regrtest.py -R:: test_bytes
2008-08-17 21:05:18 +00:00
Martin v. Löwis 64034f994c Fix memory leak: Always DECREF obj in PyBuffer_Release. 2008-08-14 20:12:06 +00:00
Martin v. Löwis 241b8345ea Make obj an owned reference in Py_buffer; this checkin
was missing from the patch for #3139.
2008-08-14 15:54:27 +00:00
Martin v. Löwis f91d46a17d Issue #3139: Make buffer-interface thread-safe wrt. PyArg_ParseTuple,
by denying s# to parse objects that have a releasebuffer procedure,
and introducing s*.

More module might need to get converted to use s*.
2008-08-12 14:49:50 +00:00
Nick Coghlan 48361f5cbf Issue 2235: Py3k warnings are now emitted for classes that will no longer inherit a__hash__ implementation from a parent class in Python 3.x. The standard library and test suite have been updated to not emit these warnings. 2008-08-11 15:45:58 +00:00
Georg Brandl 1e13ea94a3 - Issue #3537: Fix an assertion failure when an empty but presized dict
object was stored in the freelist.
2008-08-11 09:07:59 +00:00
Brett Cannon 0563a8ffd1 Change the warning emitted for using the buffer() object; memoryview() in 3.0
is not an equivalent.
2008-08-08 04:15:53 +00:00
Mark Dickinson b646757e01 Issue #1481296: (again!) Make conversion of a float NaN to an int or
long raise ValueError instead of returning 0.  Also, change the error
message for conversion of an infinity to an integer, replacing 'long' by
'integer', so that it's appropriate for both long(float('inf')) and
int(float('inf')).
2008-08-04 21:30:09 +00:00
Antoine Pitrou 92a6240198 Preemptively backport the relevant parts of r65420 2008-08-02 21:58:05 +00:00
Amaury Forgeot d'Arc 06847b13ca Correct a crash when two successive unicode allocations fail with a MemoryError:
the freelist contained half-initialized objects with freed pointers.

The comment
/* XXX UNREF/NEWREF interface should be more symmetrical */
was copied from tupleobject.c, and appears in some other places.
I sign the petition.
2008-07-31 23:39:05 +00:00
Neal Norwitz e7d8be80ba Security patches from Apple: prevent int overflow when allocating memory 2008-07-31 17:17:14 +00:00
Benjamin Peterson c0bf76d3cf backport r64751 2008-07-30 17:45:10 +00:00
Antoine Pitrou 4982d5d04a #2242: utf7 decoding crashes on bogus input on some Windows/MSVC versions 2008-07-25 17:45:59 +00:00
Raymond Hettinger 7f59b5cc03 Convert from long to Py_ssize_t. 2008-07-24 07:04:55 +00:00
Gregory P. Smith 0470bab697 Issue #2620: Overflow checking when allocating or reallocating memory
was not always being done properly in some python types and extension
modules.  PyMem_MALLOC, PyMem_REALLOC, PyMem_NEW and PyMem_RESIZE have
all been updated to perform better checks and places in the code that
would previously leak memory on the error path when such an allocation
failed have been fixed.
2008-07-22 04:46:32 +00:00
Amaury Forgeot d'Arc e4921fec01 Issue2378: pdb would delete free variables when stepping into a class statement.
The problem was introduced by r53954, the correction is to restore the symmetry between
PyFrame_FastToLocals and PyFrame_LocalsToFast
2008-07-21 22:00:38 +00:00
Neal Norwitz c86b54cb03 Fix a couple of names in error messages that were wrong 2008-07-20 19:35:23 +00:00
Eric Smith d6c393ab2b Backed out r65069, pending fixing it in Windows. 2008-07-17 19:49:47 +00:00
Eric Smith 454816d8bd Issue 3382: Make '%F' and float.__format__('F') convert results to upper case. 2008-07-17 17:48:39 +00:00
Georg Brandl 3238a3e329 Backport part of r65043. 2008-07-16 23:17:46 +00:00
Georg Brandl 3e75846cf6 Use _getbytevalue() in init too. 2008-07-16 23:10:05 +00:00
Georg Brandl 3e483f643d #3156: fix consistency in what type bytearray methods accept as items.
Also rename confusing "item" parameters to "index".
2008-07-16 22:57:41 +00:00
Eric Smith 4cb965ca91 Renamed a parameter in calc_number_widths, for consistency with the same parameter in fill_non_digits. 2008-07-16 18:29:51 +00:00
Eric Smith a5fa5a218d Complete issue 3083: add alternate (#) formatting to bin, oct, hex in str.format(). 2008-07-16 00:11:49 +00:00
Mark Dickinson 7103aa42c0 Issue #3008: add instance method float.hex and class method float.fromhex
to convert floats to and from hexadecimal strings respectively.
2008-07-15 19:08:33 +00:00
Nick Coghlan 53663a695e Issue 2235: __hash__ is once again inherited by default, but inheritance can be blocked explicitly so that collections.Hashable remains meaningful 2008-07-15 14:27:37 +00:00
Eric Smith d0c841243c Added '#' formatting to integers. This adds the 0b, 0o, or 0x prefix for bin, oct, hex. There's still one failing case, and I need to finish the docs. I hope to finish those today. 2008-07-15 10:10:07 +00:00
Robert Schuppenies 9be2ec109b Added additional __sizeof__ implementations and addressed comments made in
Issue3122.
2008-07-10 15:24:04 +00:00
Nick Coghlan 524b7773cc Issue 2517: Allow unicode messages in Exceptions again by correctly bypassing the instance dictionary when looking up __unicode__ on new-style classes 2008-07-08 14:08:04 +00:00
Skip Montanaro 2c7ca9bb11 Correct grammar. 2008-07-07 11:16:14 +00:00
Gregory P. Smith 2fe77060eb - Issue #2862: Make int and float freelist management consistent with other
freelists.  Changes their CompactFreeList apis into ClearFreeList apis and
  calls them via gc.collect().
2008-07-06 03:35:58 +00:00
Mark Dickinson bf9f4d8015 Issue 3188: accept float('infinity') as well as float('inf'). This
makes the float constructor behave in the same way as specified
by various other language standards, including C99, IEEE 754r,
and the IBM Decimal standard.
2008-07-05 11:33:52 +00:00
Raymond Hettinger a27474c345 Issue 3230: Do not the set specific size macro. 2008-06-28 22:16:53 +00:00
Robert Schuppenies 161b92103c Corrected inconsistencies in sizeof tests and addressed issue pointed
out by Jean Brouwers.
2008-06-26 15:20:35 +00:00
Raymond Hettinger 9c437af4eb Revert 64424, 64438, and 64439. 2008-06-24 22:46:07 +00:00
Eric Smith 5dce7e9a83 Fixed formatting with thousands separator and padding. Resolves issue 3140. 2008-06-24 11:11:59 +00:00
Eric Smith 9ea1e36957 Typo in comment. 2008-06-24 06:05:30 +00:00
Eric Smith 65fe47b931 Modified interface to _Py_[String|Unicode]InsertThousandsGrouping, in anticipation of fixing issue 3140. 2008-06-24 00:42:10 +00:00
Andrew M. Kuchling d897264464 Docstring typo 2008-06-21 13:29:12 +00:00
Hye-Shik Chang 30fa13f3a0 Fix build on FreeBSD gcc. 2008-06-21 11:15:30 +00:00
Raymond Hettinger e0e711446b Issue 3008: hex/oct/bin can show floats exactly. 2008-06-21 06:39:53 +00:00