summaryrefslogtreecommitdiffstats
path: root/Objects/stringobject.c
Commit message (Collapse)AuthorAgeFilesLines
* 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.)
* SF patch #659536: Use PyArg_UnpackTuple where possible.Raymond Hettinger2002-12-291-1/+1
| | | | | | | Obtain cleaner coding and a system wide performance boost by using the fast, pre-parsed PyArg_Unpack function instead of PyArg_ParseTuple function which is driven by a format string.
* Patch #650653: Raise always value error if the table is not 256 bytes long.Martin v. Löwis2002-12-121-6/+6
|
* Patch #614055: Support OpenVMS.Martin v. Löwis2002-12-061-1/+5
|
* Add nb_remainder (i.e. __mod__) slot to str type. Fixes SF bug #615506.Neil Schemenauer2002-11-181-2/+22
|
* Fix SF # 635969, No error "not all arguments converted"Neal Norwitz2002-11-121-1/+2
| | | | | | | | | When mwh added extended slicing, strings and unicode became mappings. Thus, dict was set which prevented an error when doing: newstr = 'format without a percent' % string_value This fix raises an exception again when there are no formats and % with a string value.
* Back out #479898.Martin v. Löwis2002-10-111-69/+15
|
* Fix a nasty endcase reported by Armin Rigo in SF bug 618623:Guido van Rossum2002-10-111-2/+6
| | | | | | | | | | | | | '%2147483647d' % -123 segfaults. This was because an integer overflow in a comparison caused the string resize to be skipped. After fixing the overflow, this could call _PyString_Resize() with a negative size, so I (1) test for that and raise MemoryError instead; (2) also added a test for negative newsize to _PyString_Resize(), raising SystemError as for all bad arguments. An identical bug existed in unicodeobject.c, of course. Will backport to 2.2.2.
* Undo this part of the previous checkin:Guido van Rossum2002-10-091-3/+4
| | | | | | | | | Also fixed an error message -- %s argument has non-string str() doesn't make sense for %r, so the error message now differentiates between %s and %r. because PyObject_Repr() and PyObject_Str() ensure that this can never happen. Added a helpful comment instead.
* The string formatting code has a test to switch to Unicode when %sGuido van Rossum2002-10-091-2/+5
| | | | | | | | | | | | | | sees a Unicode argument. Unfortunately this test was also executed for %r, because %s and %r share almost all of their code. This meant that, if u is a unicode object while repr(u) is an 8-bit string containing ASCII characters, '%r' % u is a *unicode* string containing only ASCII characters! Fixed by executing the test only for %s. Also fixed an error message -- %s argument has non-string str() doesn't make sense for %r, so the error message now differentiates between %s and %r.
* Include wctype.h.Martin v. Löwis2002-10-071-1/+2
|
* Patch #479898: Use multibyte C library for printing strings if available.Martin v. Löwis2002-10-071-15/+68
|
* Fix warnings on 64-bit platforms about casts from pointers to ints.Guido van Rossum2002-09-121-1/+2
| | | | Two of these were real bugs.
* Fix escaping of non-ASCII characters.Martin v. Löwis2002-09-091-2/+4
|
* Check whether a string resize is necessary at the endWalter Dörwald2002-09-031-3/+4
| | | | | | | | | of PyString_DecodeEscape(). This prevents a call to _PyString_Resize() for the empty string, which would result in a PyErr_BadInternalCall(), because the empty string has more than one reference. This closes SF bug http://www.python.org/sf/603937
* PEP 293 implemention (from SF patch http://www.python.org/sf/432401)Walter Dörwald2002-09-021-2/+6
|
* string_contains(): speed up by avoiding function calls whereGuido van Rossum2002-08-241-9/+12
| | | | | | possible. This always called PyUnicode_Check() and PyString_Check(), at least one of which would call PyType_IsSubtype(). Also, this would call PyString_Size() on known string objects.
* Code by Inyeol Lee, submitted to SF bug 595350, to implementGuido van Rossum2002-08-231-24/+33
| | | | | the string/unicode method .replace() with a zero-lengt first argument. Inyeol contributed tests for this too.
* Fix some endcase bugs in unicode rfind()/rindex() and endswith().Guido van Rossum2002-08-201-1/+1
| | | | | | These were reported and fixed by Inyeol Lee in SF bug 595350. The endswith() bug was already fixed in 2.3, but this adds some more test cases.
* SF patch 576101, by Oren Tirosh: alternative implementation ofGuido van Rossum2002-08-191-71/+108
| | | | | | | | interning. I modified Oren's patch significantly, but the basic idea and most of the implementation is unchanged. Interned strings created with PyString_InternInPlace() are now mortal, and you must keep a reference to the resulting string around; use the new function PyString_InternImmortal() to create immortal interned strings.
* Call me anal, but there was a particular phrase that was speading toGuido van Rossum2002-08-191-3/+3
| | | | | | | comments everywhere that bugged me: /* Foo is inlined */ instead of /* Inline Foo */. Somehow the "is inlined" phrase always confused me for half a second (thinking, "No it isn't" until I added the missing "here"). The new phrase is hopefully unambiguous.
* Get this to compile again if Py_USING_UNICODE is not defined.Neal Norwitz2002-08-161-1/+1
| | | | com_error() is static in Python/compile.c.
* More changes of DeprecationWarning to FutureWarning.Guido van Rossum2002-08-141-1/+1
|
* Check for trailing backslash. Fixes #593656.Martin v. Löwis2002-08-141-5/+8
|
* Patch #505705: Remove eval in pickle and cPickle.Martin v. Löwis2002-08-141-3/+157
|
* Implement stage B0 of PEP 237: add warnings for operations thatGuido van Rossum2002-08-111-0/+6
| | | | | | | | | | currently return inconsistent results for ints and longs; in particular: hex/oct/%u/%o/%x/%X of negative short ints, and x<<n that either loses bits or changes sign. (No warnings for repr() of a long, though that will also change to lose the trailing 'L' eventually.) This introduces some warnings in the test suite; I'll take care of those later.
* Committing patch #591250 which provides "str1 in str2" when str1 is aBarry Warsaw2002-08-061-9/+16
| | | | string of longer than 1 character.