summaryrefslogtreecommitdiff
path: root/Objects/stringobject.c
AgeCommit message (Collapse)AuthorLines
2010-01-25#7775: fixed docstring for rpartitionEzio Melotti-1/+1
2010-01-13Issue #7622: Improve the split(), rsplit(), splitlines() and replace()Antoine Pitrou-469/+51
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-31/+10
`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-2/+0
case. Much of the patch came from Mark Dickinson.
2009-11-23Issue #7117, continued: Remove substitution of %g-style formatting forMark Dickinson-3/+0
%f-style formatting, which used to occur at high precision. Float formatting should now be consistent between 2.7 and 3.1.
2009-11-23Remove restriction on precision when formatting floats. This is theMark Dickinson-57/+21
first step towards removing the %f -> %g switch (see issues 7117, 5859).
2009-11-15Issue #7228: Add '%lld' and '%llu' support to PyFormat_FromString,Mark Dickinson-12/+59
PyFormat_FromStringV and PyErr_Format.
2009-10-26Finished removing _PyOS_double_to_string, as mentioned in issue 7117.Eric Smith-3/+17
2009-10-14#7116: str.join() takes an iterable.Georg Brandl-2/+2
2009-09-18add keyword arguments support to str/unicode encode and decode #6300Benjamin Peterson-6/+10
2009-09-17use macrosBenjamin Peterson-1/+1
2009-08-28Silence gcc 'comparison always false' warningMark Dickinson-1/+3
2009-04-25Issue #5835, deprecate PyOS_ascii_formatd.Eric Smith-7/+2
If anyone wants to clean up the documentation, feel free. It's my first documentation foray, and it's not that great. Will port to py3k with a different strategy.
2009-03-29Issue #532631: Add paranoid check to avoid potential buffer overflowMark Dickinson-1/+10
on systems with sizeof(int) > 4.
2009-03-29Issue #532631: Replace confusing fabs(x)/1e25 >= 1e25 testMark Dickinson-1/+1
with fabs(x) >= 1e50, and fix documentation.
2009-01-07Issue #4850: Change COUNT_ALLOCS variables to Py_ssize_t.Martin v. Löwis-1/+1
2008-12-05Issue #4445: save 3 bytes (on average, on a typical machine) perMark Dickinson-13/+21
string allocation.
2008-10-04Docstring change for *partition: use same tense as other docstrings.Andrew M. Kuchling-7/+7
Hyphenate left- and right-justified. Fix 'registerd' typo
2008-09-01Issue #3751: str.rpartition would perform a left-partition when called withAmaury Forgeot d'Arc-1/+1
a unicode argument. will backport.
2008-08-12Issue #3139: Make buffer-interface thread-safe wrt. PyArg_ParseTuple,Martin v. Löwis-3/+4
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-02Preemptively backport the relevant parts of r65420Antoine Pitrou-1/+1
2008-07-31Security patches from Apple: prevent int overflow when allocating memoryNeal Norwitz-2/+17
2008-07-17Backed out r65069, pending fixing it in Windows.Eric Smith-8/+5
2008-07-17Issue 3382: Make '%F' and float.__format__('F') convert results to upper case.Eric Smith-5/+8
2008-06-10Rename bytesobject.c back to stringobject.c to keep with the PyString theme.Gregory P. Smith-0/+5215
Part of reverting most of r63675 per the mailing list discussion.
2008-05-26Renamed bytesobject.c to bytearrayobject.cChristian Heimes-5176/+0
Renamed stringobject.c to bytesobject.c Fixed Windows builds
2008-05-26Renamed PyString to PyBytesChristian Heimes-481/+481
2008-05-26First step of the C API rename:Christian Heimes-2/+2
renamed Include/bytesobject.h to Include/bytearrayobject.h renamed Include/stringobject.h to Include/bytesobject.h added Include/stringobject.h with aliases
2008-05-11#2809 followup: even better split docstring.Georg Brandl-2/+2
2008-05-11Addresses issue 2802: 'n' formatting for integers.Eric Smith-0/+4
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#2809: elaborate str.split docstring a bit.Georg Brandl-1/+2
2008-04-10get rid of assert (size >= 0) now that an explicit if (size < 0) is in the code.Gregory P. Smith-1/+0
2008-04-09Raise SystemError when size < 0 is passed into PyString_FromStringAndSize,Gregory P. Smith-0/+5
PyBytes_FromStringAndSize or PyUnicode_FromStringAndSize. [issue2587]
2008-03-26Merged revisions ↵Christian Heimes-1/+13
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-11Fix the overflows in expandtabs(). "This time for sure!"Guido van Rossum-25/+32
(Exploit at request.)
2008-02-24Issue 1742669. Now %d accepts very big float numbers.Facundo Batista-16/+46
Thanks Gabriel Genellina.
2008-02-17Backport of PEP 3101, Advanced String Formatting, from py3k.Eric Smith-9/+20
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-12-19#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and ↵Christian Heimes-64/+64
Py_REFCNT. Macros for b/w compatibility are available.
2007-12-08When splitting, avoid making a copy of the string if the split doesn't findSkip Montanaro-11/+42
anything (issue 1538).
2007-11-16Now in find, rfind, index, and rindex, you can use None as defaults,Facundo Batista-2/+13
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.
2007-11-06Add missing "return NULL" in overflow check in PyObject_Repr().Guido van Rossum-0/+1
2007-10-29Backport fixes for the code that decodes octal escapes (and for PyStringGuido van Rossum-4/+6
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.)
2007-09-17Add a bunch of GIL release/acquire points in tp_print implementations and forBrett Cannon-2/+10
PyObject_Print(). Closes issue #1164.
2007-08-28Improve extended slicing support in builtin types and classes. Specifically:Thomas Wouters-0/+11
- Specialcase extended slices that amount to a shallow copy the same way as is done for simple slices, in the tuple, string and unicode case. - Specialcase step-1 extended slices to optimize the common case for all involved types. - For lists, allow extended slice assignment of differing lengths as long as the step is 1. (Previously, 'l[:2:1] = []' failed even though 'l[:2] = []' and 'l[:2:None] = []' do not.) - Implement extended slicing for buffer, array, structseq, mmap and UserString.UserString. - Implement slice-object support (but not non-step-1 slice assignment) for UserString.MutableString. - Add tests for all new functionality.
2007-07-29Bug #1763149: use proper slice syntax in docstring.Georg Brandl-2/+2
(backport)
2007-07-21PEP 3123: Provide forward compatibility with Python 3.0, while keepingMartin v. Löwis-68/+66
backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and PyVarObject_HEAD_INIT.
2007-07-12Patch #1673759: add a missing overflow check when formatting floatsGeorg Brandl-1/+2
with %G.
2007-06-11Fix a bug when there was a newline in the string expandtabs was called on.Neal Norwitz-2/+8
This also catches another condition that can overflow. Will backport.
2007-06-09Prevent expandtabs() on string and unicode objects from causing a segfault whenNeal Norwitz-3/+14
a large width is passed on 32-bit platforms. Found by Google. It would be good for people to review this especially carefully and verify I don't have an off by one error and there is no other way to cause overflow.
2007-04-12SF 1193128: Let str.translate(None) be an identity transformationRaymond Hettinger-8/+16