Commit Graph

74 Commits

Author SHA1 Message Date
Mark Dickinson 75d3600466 Issue #14700: Fix buggy overflow checks for large precision and width in new-style and old-style formatting. 2012-10-28 10:00:46 +00:00
Jesus Cea 44e81687a2 startswith and endswith don't accept None as slice index. Patch by Torsten Becker. (closes #11828) 2011-04-20 16:39:15 +02:00
Ezio Melotti 24b07bcba3 #11515: fix several typos. Patch by Piotr Kasprzyk. 2011-03-15 18:55:01 +02:00
Florent Xicluna 172e15fdd6 Merged revisions 83833,83838-83839,83859,83878 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r83833 | florent.xicluna | 2010-08-08 18:25:27 +0200 (dim., 08 août 2010) | 2 lines

  Add test case for the HTTPResponse being an iterable.  Follow-up of issue #4608.
........
  r83838 | florent.xicluna | 2010-08-08 20:03:44 +0200 (dim., 08 août 2010) | 2 lines

  Typo.
........
  r83839 | florent.xicluna | 2010-08-08 20:06:13 +0200 (dim., 08 août 2010) | 2 lines

  Issue #7564: Skip test_ioctl if another process is attached to /dev/tty.
........
  r83859 | florent.xicluna | 2010-08-09 00:07:16 +0200 (lun., 09 août 2010) | 2 lines

  Fix #8530: Prevent stringlib fastsearch from reading beyond the front of an array.
........
  r83878 | florent.xicluna | 2010-08-09 10:29:08 +0200 (lun., 09 août 2010) | 1 line

  Merge the 2to3 script from /sandbox/trunk/2to3/2to3, revision 72867 (latest).
........
2010-08-09 20:02:00 +00:00
Mark Dickinson aad57bd1bb Merged revisions 83400 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r83400 | mark.dickinson | 2010-08-01 11:41:49 +0100 (Sun, 01 Aug 2010) | 7 lines

  Issue #9416: Fix some issues with complex formatting where the
  output with no type specifier failed to match the str output:

    - format(complex(-0.0, 2.0), '-') omitted the real part from the output,
    - format(complex(0.0, 2.0), '-') included a sign and parentheses.
........
2010-08-01 10:45:15 +00:00
Benjamin Peterson 7dbe3e31c1 remove extra byte and fix comment 2010-06-07 22:32:44 +00:00
Benjamin Peterson 13e934acc0 correctly overflow when indexes are too large 2010-06-07 22:23:23 +00:00
Benjamin Peterson c4afe2950a locale grouping strings should end in '\0' 2010-06-07 21:37:09 +00:00
Antoine Pitrou c83ea137d7 Untabify C files. Will watch buildbots. 2010-05-09 14:46:46 +00:00
Eric Smith 87bcb243ac Issue #6902: Fix problem with built-in types format incorrectly with 0 padding. 2010-02-23 00:11:16 +00:00
Eric Smith f32d4acead Issue #7988: Fix default alignment to be right aligned for complex.__format__. Now it matches other numeric types. 2010-02-22 18:33:47 +00:00
Georg Brandl aee900338e Add note about usage of STRINGLIB_EMPTY. 2010-01-17 12:14:42 +00:00
Antoine Pitrou 10042922d9 Sanitize bloom filter macros 2010-01-13 14:01:26 +00:00
Antoine Pitrou a913a20c91 Test commit to try to diagnose failures of the IA-64 buildbot 2010-01-13 13:43:37 +00:00
Antoine Pitrou 6467213bfd Issue #7622: Improve the split(), rsplit(), splitlines() and replace()
methods of bytes, bytearray and unicode objects by using a common
implementation based on stringlib's fast search.  Patch by Florent Xicluna.
2010-01-13 07:55:48 +00:00
Antoine Pitrou 5b7139aab4 Issue #7462: Implement the stringlib fast search algorithm for the `rfind`,
`rindex`, `rsplit` and `rpartition` methods.  Patch by Florent Xicluna.
2010-01-02 21:12:58 +00:00
Eric Smith c4ab8339e9 Issue #3382: Make '%F' and float.__format__('F') convert results to upper case. Much of the patch came from Mark Dickinson. 2009-11-29 17:40:57 +00:00
Mark Dickinson 9dd5e16c5d Issue #7117, continued: Remove substitution of %g-style formatting for
%f-style formatting, which used to occur at high precision.  Float formatting
should now be consistent between 2.7 and 3.1.
2009-11-23 20:54:09 +00:00
Eric Smith 5c4a5d2911 Issue 6330: Fix --enable-unicode=ucs4. 2009-07-30 13:39:44 +00:00
Eric Smith e94a826304 Sync trunk and py3k versions of string formatting. Will manually merge into py3k. 2009-07-27 01:58:25 +00:00
Eric Smith 4b94b192ff Issue 6089: str.format raises SystemError. 2009-05-23 13:56:13 +00:00
Eric Smith a985a3aee4 Issue #5920: Changed format.__float__ and complex.__float__ to use a precision of 12 when using the empty presentation type. This more closely matches str()'s behavior and reduces surprises when adding alignment flags to an empty format string. Patch by Mark Dickinson. 2009-05-05 18:26:08 +00:00
Eric Smith 27f204dc29 Keep py3k and trunk code in sync. 2009-05-02 09:58:09 +00:00
Georg Brandl ca87fa5a5b #5889: remove comma at the end of a list that some C compilers don't like. 2009-05-01 08:51:37 +00:00
Eric Smith 9139cc6a3b Issue #1588: Add complex.__format__. 2009-04-30 00:58:58 +00:00
Eric Smith cac7af6863 Issue #5793: rationalize isdigit / isalpha / tolower, etc. Will port to py3k. Should fix Windows buildbot errors. 2009-04-27 19:04:37 +00:00
Eric Smith ebafbb705c Fixed issue 5782: formatting with commas didn't work if no specifier type code was given. 2009-04-22 16:20:47 +00:00
Eric Smith aca19e6a74 Backport of some of the work in r71665 to trunk. This reworks much of
int, long, and float __format__(), and it keeps their implementation
in sync with py3k.

Also added PyOS_double_to_string. This is the "fallback" version
that's also available in trunk, and should be kept in sync with that
code. I'll add an issue to document PyOS_double_to_string in the C
API.

There are many internal cleanups. Externally visible changes include:

- Implement PEP 378, Format Specifier for Thousands Separator, for
  floats, ints, and longs.

- Issue #5515: 'n' formatting for ints, longs, and floats handles
  leading zero formatting poorly.

- Issue #5772: For float.__format__, don't add a trailing ".0" if
  we're using no type code and we have an exponent.
2009-04-22 13:29:05 +00:00
Eric Smith 8c023248ed Fixed incorrect object passed into format_float_internal(). This was resulting in a conversion being done twice. 2009-04-13 00:29:50 +00:00
Mark Dickinson 2e648ecc7d Issue #532631: Replace confusing fabs(x)/1e25 >= 1e25 test
with fabs(x) >= 1e50, and fix documentation.
2009-03-29 14:37:51 +00:00
Eric Smith 6f42edb682 Issue 5237, Allow auto-numbered replacement fields in str.format() strings.
For simple uses for str.format(), this makes the typing easier. Hopfully this
will help in the adoption of str.format().

For example:
'The {} is {}'.format('sky', 'blue')

You can mix and matcth auto-numbering and named replacement fields:
'The {} is {color}'.format('sky', color='blue')

But you can't mix and match auto-numbering and specified numbering:
'The {0} is {}'.format('sky', 'blue')
ValueError: cannot switch from manual field specification to automatic field numbering

Will port to 3.1.
2009-03-14 11:57:26 +00:00
Eric Smith e9fb6863da Issue #5247: Improve error message when unknown format codes are used when using str.format() with str, unicode, long, int, and float arguments. 2009-02-20 14:02:36 +00:00
Benjamin Peterson e548d2487d fix url 2009-01-20 18:58:27 +00:00
Antoine Pitrou c2f02216b6 Issue #4935: The overflow checking code in the expandtabs() method common
to str, bytes and bytearray could be optimized away by the compiler, letting
the interpreter segfault instead of raising an error.
2009-01-13 23:13:52 +00:00
Amaury Forgeot d'Arc fc5ea39289 #3967: Correct a crash in count() and find() methods of string-like objects.
For example:
   "".count("xxxx", sys.maxint, 0)

Reviewed by Benjamin Peterson.
Will port to 2.5 and 3.0.
2008-09-26 22:34:08 +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
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
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
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
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
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
Gregory P. Smith dd96db63f6 This reverts r63675 based on the discussion in this thread:
http://mail.python.org/pipermail/python-dev/2008-June/079988.html

Python 2.6 should stick with PyString_* in its codebase.  The PyBytes_* names
in the spirit of 3.0 are available via a #define only.  See the email thread.
2008-06-09 04:58:54 +00:00
Eric Smith dc13b79a38 Refactor and clean up str.format() code (and helpers) in advance of optimizations. 2008-05-30 18:10:04 +00:00
Christian Heimes 593daf545b Renamed PyString to PyBytes 2008-05-26 12:51:38 +00:00
Eric Smith cf537ff39e Addresses issue 2802: 'n' formatting for integers.
Adds 'n' as a format specifier for integers, to mirror the same
specifier which is already available for floats.  'n' is the same as
'd', but inserts the current locale-specific thousands grouping.

I added this as a stringlib function, but it's only used by str type,
not unicode.  This is because of an implementation detail in
unicode.format(), which does its own str->unicode conversion.  But the
unicode version will be needed in 3.0, and it may be needed by other
code eventually in 2.6 (maybe decimal?), so I left it as a stringlib
implementation.  As long as the unicode version isn't instantiated,
there's no overhead for this.
2008-05-11 19:52:48 +00:00