summaryrefslogtreecommitdiff
path: root/Objects/stringlib
AgeCommit message (Collapse)AuthorLines
2010-01-17Add note about usage of STRINGLIB_EMPTY.Georg Brandl-4/+5
2010-01-13Sanitize bloom filter macrosAntoine Pitrou-11/+23
2010-01-13Test commit to try to diagnose failures of the IA-64 buildbotAntoine Pitrou-2/+2
2010-01-13Issue #7622: Improve the split(), rsplit(), splitlines() and replace()Antoine Pitrou-196/+504
methods of bytes, bytearray and unicode objects by using a common implementation based on stringlib's fast search. Patch by Florent Xicluna.
2010-01-02Issue #7462: Implement the stringlib fast search algorithm for the `rfind`,Antoine Pitrou-85/+93
`rindex`, `rsplit` and `rpartition` methods. Patch by Florent Xicluna.
2009-11-29Issue #3382: Make '%F' and float.__format__('F') convert results to upper ↵Eric Smith-14/+0
case. Much of the patch came from Mark Dickinson.
2009-11-23Issue #7117, continued: Remove substitution of %g-style formatting forMark Dickinson-6/+0
%f-style formatting, which used to occur at high precision. Float formatting should now be consistent between 2.7 and 3.1.
2009-07-30Issue 6330: Fix --enable-unicode=ucs4.Eric Smith-3/+20
2009-07-27Sync trunk and py3k versions of string formatting. Will manually merge into ↵Eric Smith-0/+6
py3k.
2009-05-23Issue 6089: str.format raises SystemError.Eric Smith-2/+3
2009-05-05Issue #5920: Changed format.__float__ and complex.__float__ to use a ↵Eric Smith-4/+8
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-02Keep py3k and trunk code in sync.Eric Smith-0/+4
2009-05-01#5889: remove comma at the end of a list that some C compilers don't like.Georg Brandl-1/+1
2009-04-30Issue #1588: Add complex.__format__.Eric Smith-49/+334
2009-04-27Issue #5793: rationalize isdigit / isalpha / tolower, etc. Will port to ↵Eric Smith-11/+2
py3k. Should fix Windows buildbot errors.
2009-04-22Fixed issue 5782: formatting with commas didn't work if no specifier type ↵Eric Smith-0/+1
code was given.
2009-04-22Backport of some of the work in r71665 to trunk. This reworks much ofEric Smith-431/+664
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-13Fixed incorrect object passed into format_float_internal(). This was ↵Eric Smith-1/+1
resulting in a conversion being done twice.
2009-03-29Issue #532631: Replace confusing fabs(x)/1e25 >= 1e25 testMark Dickinson-1/+1
with fabs(x) >= 1e50, and fix documentation.
2009-03-14Issue 5237, Allow auto-numbered replacement fields in str.format() strings.Eric Smith-44/+129
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-02-20Issue #5247: Improve error message when unknown format codes are used when ↵Eric Smith-17/+31
using str.format() with str, unicode, long, int, and float arguments.
2009-01-20fix urlBenjamin Peterson-1/+1
2009-01-13Issue #4935: The overflow checking code in the expandtabs() method commonAntoine Pitrou-37/+30
to str, bytes and bytearray could be optimized away by the compiler, letting the interpreter segfault instead of raising an error.
2008-09-26#3967: Correct a crash in count() and find() methods of string-like objects.Amaury Forgeot d'Arc-8/+6
For example: "".count("xxxx", sys.maxint, 0) Reviewed by Benjamin Peterson. Will port to 2.5 and 3.0.
2008-08-24Fix:Neal Norwitz-1/+4
* 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-22Silenced compiler warningChristian Heimes-1/+1
Objects/stringlib/find.h:97: warning: 'stringlib_contains_obj' defined but not used Reviewed by Benjamin Peterson
2008-08-18Backport of r63826.Eric Smith-6/+42
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-07-17Backed out r65069, pending fixing it in Windows.Eric Smith-6/+6
2008-07-17Issue 3382: Make '%F' and float.__format__('F') convert results to upper case.Eric Smith-6/+6
2008-07-16Renamed a parameter in calc_number_widths, for consistency with the same ↵Eric Smith-32/+32
parameter in fill_non_digits.
2008-07-16Complete issue 3083: add alternate (#) formatting to bin, oct, hex in ↵Eric Smith-30/+68
str.format().
2008-07-15Added '#' formatting to integers. This adds the 0b, 0o, or 0x prefix for ↵Eric Smith-13/+43
bin, oct, hex. There's still one failing case, and I need to finish the docs. I hope to finish those today.
2008-06-24Fixed formatting with thousands separator and padding. Resolves issue 3140.Eric Smith-13/+13
2008-06-24Typo in comment.Eric Smith-1/+1
2008-06-24Modified interface to _Py_[String|Unicode]InsertThousandsGrouping, in ↵Eric Smith-20/+27
anticipation of fixing issue 3140.
2008-06-09This reverts r63675 based on the discussion in this thread:Gregory P. Smith-8/+8
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-05-30Refactor and clean up str.format() code (and helpers) in advance of ↵Eric Smith-69/+47
optimizations.
2008-05-26Renamed PyString to PyBytesChristian Heimes-9/+9
2008-05-11Addresses issue 2802: 'n' formatting for integers.Eric Smith-3/+150
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-04-07Bug #2388: Fix gcc warnings when compiling with --enable-unicode=ucs4.Martin v. Löwis-5/+24
2008-03-26Merged revisions ↵Christian Heimes-0/+472
61750,61752,61754,61756,61760,61763,61768,61772,61775,61805,61809,61812,61819,61917,61920,61930,61933-61934 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/trunk-bytearray ........ r61750 | christian.heimes | 2008-03-22 20:47:44 +0100 (Sat, 22 Mar 2008) | 1 line Copied files from py3k w/o modifications ........ r61752 | christian.heimes | 2008-03-22 20:53:20 +0100 (Sat, 22 Mar 2008) | 7 lines Take One * Added initialization code, warnings, flags etc. to the appropriate places * Added new buffer interface to string type * Modified tests * Modified Makefile.pre.in to compile the new files * Added bytesobject.c to Python.h ........ r61754 | christian.heimes | 2008-03-22 21:22:19 +0100 (Sat, 22 Mar 2008) | 2 lines Disabled bytearray.extend for now since it causes an infinite recursion Fixed serveral unit tests ........ r61756 | christian.heimes | 2008-03-22 21:43:38 +0100 (Sat, 22 Mar 2008) | 5 lines Added PyBytes support to several places: str + bytearray ord(bytearray) bytearray(str, encoding) ........ r61760 | christian.heimes | 2008-03-22 21:56:32 +0100 (Sat, 22 Mar 2008) | 1 line Fixed more unit tests related to type('') is not unicode ........ r61763 | christian.heimes | 2008-03-22 22:20:28 +0100 (Sat, 22 Mar 2008) | 2 lines Fixed more unit tests Fixed bytearray.extend ........ r61768 | christian.heimes | 2008-03-22 22:40:50 +0100 (Sat, 22 Mar 2008) | 1 line Implemented old buffer interface for bytearray ........ r61772 | christian.heimes | 2008-03-22 23:24:52 +0100 (Sat, 22 Mar 2008) | 1 line Added backport of the io module ........ r61775 | christian.heimes | 2008-03-23 03:50:49 +0100 (Sun, 23 Mar 2008) | 1 line Fix str assignement to bytearray. Assignment of a str of size 1 is interpreted as a single byte ........ r61805 | christian.heimes | 2008-03-23 19:33:48 +0100 (Sun, 23 Mar 2008) | 3 lines Fixed more tests Fixed bytearray() comparsion with unicode() Fixed iterator assignment of bytearray ........ r61809 | christian.heimes | 2008-03-23 21:02:21 +0100 (Sun, 23 Mar 2008) | 2 lines str(bytesarray()) now returns the bytes and not the representation of the bytearray object Enabled and fixed more unit tests ........ r61812 | christian.heimes | 2008-03-23 21:53:08 +0100 (Sun, 23 Mar 2008) | 3 lines Clear error PyNumber_AsSsize_t() fails Use CHARMASK for ob_svall access disabled a test with memoryview again ........ r61819 | christian.heimes | 2008-03-23 23:05:57 +0100 (Sun, 23 Mar 2008) | 1 line Untested updates to the PCBuild directory ........ r61917 | christian.heimes | 2008-03-26 00:57:06 +0100 (Wed, 26 Mar 2008) | 1 line The type system of Python 2.6 has subtle differences to 3.0's. I've removed the Py_TPFLAGS_BASETYPE flags from bytearray for now. bytearray can't be subclasses until the issues with bytearray subclasses are fixed. ........ r61920 | christian.heimes | 2008-03-26 01:44:08 +0100 (Wed, 26 Mar 2008) | 2 lines Disabled last failing test I don't understand what the test is testing and how it suppose to work. Ka-Ping, please check it out. ........ r61930 | christian.heimes | 2008-03-26 12:46:18 +0100 (Wed, 26 Mar 2008) | 1 line Re-enabled bytes warning code ........ r61933 | christian.heimes | 2008-03-26 13:20:46 +0100 (Wed, 26 Mar 2008) | 1 line Fixed a bug in the new buffer protocol. The buffer slots weren't copied into a subclass. ........ r61934 | christian.heimes | 2008-03-26 13:25:09 +0100 (Wed, 26 Mar 2008) | 1 line Re-enabled bytearray subclassing - all tests are passing. ........
2008-03-17Issue 2264: empty float presentation type needs to have at least one digit ↵Eric Smith-1/+6
past the decimal point. Added "Z" format_char to PyOS_ascii_formatd to support empty float presentation type. Renamed buf_size in PyOS_ascii_formatd to more accurately reflect it's meaning. Modified format.__float__ to use the new "Z" format as the default. Added test cases.
2008-02-24Corrected assert to check for correct type in py3k.Eric Smith-1/+1
2008-02-20Now that PyOS_ascii_formatd supports the 'n' format, simplify the float ↵Eric Smith-40/+15
formatting code to just call it.
2008-02-18Added code to correct combining str and unicode in ''.format(). Added test ↵Eric Smith-0/+16
case.
2008-02-17Backport of PEP 3101, Advanced String Formatting, from py3k.Eric Smith-0/+2273
Highlights: - Adding PyObject_Format. - Adding string.Format class. - Adding __format__ for str, unicode, int, long, float, datetime. - Adding builtin format. - Adding ''.format and u''.format. - str/unicode fixups for formatters. The files in Objects/stringlib that implement PEP 3101 (stringdefs.h, unicodedefs.h, formatter.h, string_format.h) are identical in trunk and py3k. Any changes from here on should be made to trunk, and changes will propogate to py3k).
2007-11-16Made _ParseTupleFinds only defined to unicodeobject.cFacundo Batista-0/+3
2007-11-16Fix for stupid error (I need to remember to do a full 'make clean + make'Facundo Batista-1/+1
cycle before the tests...). Sorry.
2007-11-16Now in find, rfind, index, and rindex, you can use None as defaults,Facundo Batista-0/+47
as usual with slicing (both with str and unicode strings). This fixes issue 1259. For str only the stringobject.c file was modified. But for unicode, I needed to repeat in the four functions a lot of code, so created a new function that does part of the job for them (and placed it in find.h, following a suggestion of Barry). Also added tests for this behaviour.
2006-09-04Fix endcase for str.rpartition()Raymond Hettinger-4/+4