summaryrefslogtreecommitdiffstats
path: root/Objects/stringobject.c
Commit message (Collapse)AuthorAgeFilesLines
...
* More low-hanging fruit. Still need to re-arrange some code (or find a betterAnthony Baxter2006-04-111-35/+35
| | | | | solution) in the same way as listobject.c got changed. Hoping for a better solution.
* Remove dead code (reported by HP compiler).Neal Norwitz2006-04-061-8/+5
| | | | Can probably be backported if anyone cares.
* Remove unnecessary casts in type object initializers.Georg Brandl2006-03-301-3/+3
|
* Get rid of warnings on some platforms by using %u for a size_t.Neal Norwitz2006-03-251-1/+1
|
* Use macro versions instead of function versions when we already know the type.Neal Norwitz2006-03-201-4/+5
| | | | | | | | This will hopefully get rid of some Coverity warnings, be a hint to developers, and be marginally faster. Some asserts were added when the type is currently known, but depends on values from another function.
* Introduced symbol PY_FORMAT_SIZE_T. See the new commentsTim Peters2006-03-171-31/+22
| | | | | in pyport.h. Changed PyString_FromFormatV() to use it instead of inlining its own maze of #if'ery.
* Checking in the code for PEP 357.Guido van Rossum2006-03-071-3/+6
| | | | | | This was mostly written by Travis Oliphant. I've inspected it all; Neal Norwitz and MvL have also looked at it (in an earlier incarnation).
* SF #1444030: Fix several potential defects found by Coverity.Hye-Shik Chang2006-03-071-1/+1
| | | | (reviewed by Neal Norwitz)
* Change int to Py_ssize_t in several places.Martin v. Löwis2006-03-071-4/+12
| | | | | Add (int) casts to silence compiler warnings. Raise Python exceptions for overflows.
* Revert backwards-incompatible const changes.Martin v. Löwis2006-02-271-1/+1
|
* Use Py_ssize_t in helper function between Py_ssize_t-using functions.Thomas Wouters2006-02-161-2/+2
|
* Use Py_ssize_t for counts and sizes.Martin v. Löwis2006-02-161-5/+5
| | | | Convert Py_ssize_t using PyInt_FromSsize_t
* Support %zd in PyErr_Format and PyString_FromFormat.Martin v. Löwis2006-02-161-0/+21
|
* Merge ssize_t branch.Martin v. Löwis2006-02-151-156/+157
|
* Add const to several API functions that take char *.Jeremy Hylton2005-12-101-1/+1
| | | | | | | | | | | | | | | | | | | In C++, it's an error to pass a string literal to a char* function without a const_cast(). Rather than require every C++ extension module to put a cast around string literals, fix the API to state the const-ness. I focused on parts of the API where people usually pass literals: PyArg_ParseTuple() and friends, Py_BuildValue(), PyMethodDef, the type slots, etc. Predictably, there were a large set of functions that needed to be fixed as a result of these changes. The most pervasive change was to make the keyword args list passed to PyArg_ParseTupleAndKewords() to be a const char *kwlist[]. One cast was required as a result of the changes: A type object mallocs the memory for its tp_doc slot and later frees it. PyTypeObject says that tp_doc is const char *; but if the type was created by type_new(), we know it is safe to cast to char *.
* Fix bug:Michael W. Hudson2005-10-211-4/+0
| | | | | | | | [ 1327110 ] wrong TypeError traceback in generator expressions by removing the code that can stomp on the users' TypeError raised by the iterable argument to ''.join() -- PySequence_Fast (now?) gives a perfectly reasonable message itself. Also, a couple of tests.
* SF bug #1331563 ] string_subscript doesn't check for failed PyMem_Malloc. ↵Neal Norwitz2005-10-201-0/+2
| | | | Will backport
* Fix PyString_Format so that the "%s" format works again when Unicode is notGeorg Brandl2005-10-011-0/+2
| | | | enabled.
* Fix bug in last checkin (2.231). To match previous behavior, unicodeNeil Schemenauer2005-08-311-0/+5
| | | | | subclasses should be substituted as-is and not have tp_str called on them.
* Change the %s format specifier for str objects so that it returns aNeil Schemenauer2005-08-121-8/+4
| | | | | unicode instance if the argument is not an instance of basestring and calling __str__ on the argument returns a unicode instance.
* SF bug #1224347: int/long unification and hex()Raymond Hettinger2005-06-291-11/+5
| | | | Hex longs now print with lowercase letters like their int counterparts.
* * Beef-up tests for str.count().Raymond Hettinger2005-02-201-2/+7
| | | | * Speed-up str.count() by using memchr() to fly between first char matches.
* * Beef-up testing of str.__contains__() and str.find().Raymond Hettinger2005-02-201-13/+26
| | | | | | | | | | | | | | | | | | | * Speed-up "x in y" where x has more than one character. The existing code made excessive calls to the expensive memcmp() function. The new code uses memchr() to rapidly find a start point for memcmp(). In addition to knowing that the first character is a match, the new code also checks that the last character is a match. This significantly reduces the incidence of false starts (saving memcmp() calls and making quadratic behavior less likely). Improves the timings on: python -m timeit -r7 -s"x='a'*1000" "'ab' in x" python -m timeit -r7 -s"x='a'*1000" "'bc' in x" Once this code has proven itself, then string_find_internal() should refer to it rather than running its own version. Also, something similar may apply to unicode objects.
* More bug #1077106 stuff, sorry -- modem induced impatiece!Michael W. Hudson2005-01-311-0/+1
| | | | This should go on whatever bugfix branches the other fetches up on.
* SF bug #1054139: serious string hashing error in 2.4b1Raymond Hettinger2004-10-261-0/+1
| | | | | _PyString_Resize() readied strings for mutation but did not invalidate the cached hash value.
* SF Patch #1007087: Return new string for single subclass joins (Bug #1001011)Raymond Hettinger2004-08-231-12/+8
| | | | | | | (Patch contributed by Nick Coghlan.) Now joining string subtypes will always return a string. Formerly, if there were only one item, it was returned unchanged.
* This was quite a dark bug in my recent in-place string concatenationArmin Rigo2004-08-071-1/+2
| | | | | | hack: it would resize *interned* strings in-place! This occurred because their reference counts do not have their expected value -- stringobject.c hacks them. Mea culpa.
* Fixed some compiler warnings.Armin Rigo2004-08-071-2/+2
|
* Subclasses of string can no longer be interned. The semantics ofJeremy Hylton2004-08-071-22/+12
| | | | | | | | | | | interning were not clear here -- a subclass could be mutable, for example -- and had bugs. Explicitly interning a subclass of string via intern() will raise a TypeError. Internal operations that attempt to intern a string subclass will have no effect. Added a few tests to test_builtin that includes the old buggy code and verifies that calls like PyObject_SetAttr() don't fail. Perhaps these tests should have gone in test_string.
* .encode()/.decode() patch part 2.Marc-André Lemburg2004-07-081-0/+10
|
* Allow string and unicode return types from .encode()/.decode()Marc-André Lemburg2004-07-081-2/+24
| | | | | methods on string and unicode objects. Added unicode.decode() which was missing for no apparent reason.
* sizeof(char) is 1, by definition, so get rid of that expression inTim Peters2004-06-271-12/+7
| | | | places it's just noise.
* Patch #774665: Make Python LC_NUMERIC agnostic.Martin v. Löwis2004-06-081-1/+1
|
* [SF #866875] Add a specialized routine for one characterHye-Shik Chang2004-01-051-45/+95
| | | | separaters on str.split() and str.rsplit().
* There are places in Python which assume bytes have 8-bits. Formalize that aSkip Montanaro2003-12-221-4/+0
| | | | | | bit by checking the value of UCHAR_MAX in Include/Python.h. There was a check in Objects/stringobject.c. Remove that. (Note that we don't define UCHAR_MAX if it's not defined as the old test did.)
* Add rsplit method for str and unicode builtin types.Hye-Shik Chang2003-12-151-0/+124
| | | | | SF feature request #801847. Original patch is written by Sean Reifschneider.
* - Removed FutureWarnings related to hex/oct literals and conversionsGuido van Rossum2003-11-291-17/+19
| | | | | | | | | | and left shifts. (Thanks to Kalle Svensson for SF patch 849227.) This addresses most of the remaining semantic changes promised by PEP 237, except for repr() of a long, which still shows the trailing 'L'. The PEP appears to promise warnings for operations that changed semantics compared to Python 2.3, but this is not implemented; we've suffered through enough warnings related to hex/oct literals and I think it's best to be silent now.
* Add optional fillchar argument to ljust(), rjust(), and center() string methods.Raymond Hettinger2003-11-261-13/+18
|
* Avoid confusing name for the 3rd argument to str.replace().Fred Drake2003-10-221-3/+3
| | | | This closes SF bug #827260.
* Patch #825679: Clarify semantics of .isfoo on empty strings.Martin v. Löwis2003-10-181-12/+13
| | | | Backported to 2.3.
* SF bug #795506: Wrong handling of string format code for float values.Raymond Hettinger2003-08-271-0/+3
| | | | | | Adding missing support for '%F'. Will backport to 2.3.1.
* Fix whitespace.Walter Dörwald2003-06-181-1/+1
|
* Attempt to make all the various string *strip methods the same.Neal Norwitz2003-04-101-9/+9
| | | | | | | | | | | * Doc - add doc for when functions were added * UserString * string object methods * string module functions 'chars' is used for the last parameter everywhere. These changes will be backported, since part of the changes have already been made, but they were inconsistent.
* Reformat a few docstrings that caused line wraps in help() output.Guido van Rossum2003-04-091-6/+6
|
* Fix PyString_Format() so that '%c' % u'a' returns u'a'Walter Dörwald2003-03-311-0/+7
| | | | | | | | instead of raising a TypeError. (From SF patch #710127) Add tests to verify this is fixed. Add various tests for '%c' % int.
* Implement appropriate __getnewargs__ for all immutable subclassable builtinGuido van Rossum2003-01-291-0/+7
| | | | | | | | types. The special handling for these can now be removed from save_newobj(). Add some testing for this. Also add support for setting the 'fast' flag on the Python Pickler class, which suppresses use of the memo.
* SF patch #664192 bug #661913: inconsistent error messages between stringRaymond Hettinger2003-01-151-2/+2
| | | | | | and unicode Patch by Christopher Blunck.
* GvR's idea to use memset() for the most common special case of repeatingRaymond Hettinger2003-01-061-1/+5
| | | | | a single character. Shaves another 10% off the running time by avoiding the lg2(N) loops and cache effects for the other cases.
* Optimize string_repeat.Raymond Hettinger2003-01-061-2/+11
| | | | | | | | | | | Christian Tismer pointed out the high cost of the loop overhead and function call overhead for 'c' * n where n is large. Accordingly, the new code only makes lg2(n) loops. Interestingly, 'c' * 1000 * 1000 ran a bit faster with old code. At some point, the loop and function call overhead became cheaper than invalidating the cache with lengthy memcpys. But for more typical sizes of n, the new code runs much faster and for larger values of n it runs only a bit slower.
* Patch for bug #659709: bogus computation of float lengthMarc-André Lemburg2002-12-291-6/+16
| | | | | Python 2.2.x backport candidate. (This bug has been around since Python 1.6.)