summaryrefslogtreecommitdiffstats
path: root/Lib/test/string_tests.py
Commit message (Collapse)AuthorAgeFilesLines
* Merged revisions ↵Christian Heimes2008-03-261-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. ........
* Issue 1742669. Now %d accepts very big float numbers.Facundo Batista2008-02-241-0/+9
| | | | Thanks Gabriel Genellina.
* Now in find, rfind, index, and rindex, you can use None as defaults,Facundo Batista2007-11-161-0/+28
| | | | | | | | | | | | 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.
* Improve extended slicing support in builtin types and classes. Specifically:Thomas Wouters2007-08-281-2/+12
| | | | | | | | | | | | | | | | | | | | - 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.
* Fix a bug when there was a newline in the string expandtabs was called on.Neal Norwitz2007-06-111-0/+5
| | | | | | This also catches another condition that can overflow. Will backport.
* Fix those parts in the testsuite that assumed that sys.maxint would cause ↵Kristján Valur Jónsson2007-05-031-2/+2
| | | | overflow on x64. Now the testsuite is well behaved on that platform.
* Whitespace normalization. Ugh, we really need to do this more often.Neal Norwitz2007-04-251-2/+2
| | | | You might want to review this change as it's my first time. Be gentle. :-)
* SF 1193128: Let str.translate(None) be an identity transformationRaymond Hettinger2007-04-121-0/+3
|
* Fix endcase for str.rpartition()Raymond Hettinger2006-09-041-1/+1
|
* Bug #1515471: string.replace() accepts character buffers again.Neal Norwitz2006-07-301-2/+7
| | | | Pass the char* and size around rather than PyObject's.
* Apply perky's fix for #1503157: "/".join([u"", u""]) raising OverflowError.Georg Brandl2006-06-101-0/+2
| | | | Also improve error message on overflow.
* RFE #1491485: str/unicode.endswith()/startswith() now accept a tuple as ↵Georg Brandl2006-06-091-1/+31
| | | | first argument.
* Re-enable a new empty-string test added during the NFS sprint,Tim Peters2006-06-011-6/+1
| | | | | | but disabled then because str and unicode strings gave different results. The implementations were repaired later during the sprint, but the new test remained disabled.
* changed count to return 0 for slices outside the source stringFredrik Lundh2006-05-301-1/+2
|
* changed find/rfind to return -1 for matches outside the source stringFredrik Lundh2006-05-301-0/+8
|
* fixed "abc".count("", 100) == -96 error (hopefully, nobody's relying onFredrik Lundh2006-05-291-0/+8
| | | | the current behaviour ;-)
* needspeed: rpartition documentation, tests, and a bug fixes.Fredrik Lundh2006-05-261-2/+17
| | | | feel free to add more tests and improve the documentation.
* Test for more edge strip cases; leading and trailing separator gets removedAndrew Dalke2006-05-261-0/+2
| | | | even with strip(..., 0)
* Added more rstrip tests, including for prealloc'ed arraysAndrew Dalke2006-05-261-1/+54
|
* Test cases for off-by-one errors in string split with multicharacter pattern.Andrew Dalke2006-05-261-0/+2
|
* I like tests.Andrew Dalke2006-05-261-0/+32
| | | | | | | The new split functions use a preallocated list. Added tests which exceed the preallocation size, to exercise list appends/resizes. Also added more edge case tests.
* Added split whitespace checks for characters other than space.Andrew Dalke2006-05-261-0/+1
|
* Added a few more test cases for whitespace split. These strings have ↵Andrew Dalke2006-05-261-0/+7
| | | | leading whitespace.
* needforspeed: partition implementation, part two.Fredrik Lundh2006-05-261-0/+15
| | | | feel free to improve the documentation and the docstrings.
* Whitespace normalization.Tim Peters2006-05-251-2/+2
|
* needforspeed: check for overflow in replace (from Andrew Dalke)Fredrik Lundh2006-05-251-9/+8
|
* Added tests for implementation error we came up with in the need for speed ↵Andrew Dalke2006-05-251-0/+19
| | | | sprint.
* Disable the damn empty-string replace test -- it can'tTim Peters2006-05-241-2/+2
| | | | | be make to pass now for unicode if it passes for str, or vice versa.
* We can't leave the checked-in tests broken.Tim Peters2006-05-241-5/+10
|
* Added a slew of test for string replace, based various corner cases fromAndrew Dalke2006-05-241-0/+157
| | | | | | | | | | the Need For Speed sprint coding. Includes commented out overflow tests which will be uncommented once the code is fixed. This test will break the 8-bit string tests because "".replace("", "A") == "" when it should == "A" We have a fix for it, which should be added tomorrow.
* Merge ssize_t branch.Martin v. Löwis2006-02-151-1/+3
|
* Fix bug:Michael W. Hudson2005-10-211-0/+9
| | | | | | | | [ 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.
* Disable encoding/decoding test, if unicode is disabled.Walter Dörwald2005-07-281-19/+20
|
* * Beef-up tests for str.count().Raymond Hettinger2005-02-201-0/+28
| | | | * 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-0/+24
| | | | | | | | | | | | | | | | | | | * 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.
* SF bug #1054139: serious string hashing error in 2.4b1Raymond Hettinger2004-10-261-0/+9
| | | | | _PyString_Resize() readied strings for mutation but did not invalidate the cached hash value.
* test_bug1001011(): Verify thatTim Peters2004-08-271-5/+33
| | | | | | | | | s.join([t]) is t for (s, t) in (str, str), (unicode, unicode), and (str, unicode). For (unicode, str), verify that it's *not* t (the result is promoted to unicode instead). Also verify that when t is a subclass of str or unicode that "the right thing" happens.
* Move test_bug1001011() to string_tests.MixinStrUnicodeTest so thatWalter Dörwald2004-08-261-0/+19
| | | | | | it can be used for str and unicode. Drop the test for "".join([s]) is s because this is an implementation detail (and doesn't work for unicode)
* SF #989185: Drop unicode.iswide() and unicode.width() and addHye-Shik Chang2004-08-041-25/+0
| | | | | | | | | | | | unicodedata.east_asian_width(). You can still implement your own simple width() function using it like this: def width(u): w = 0 for c in unicodedata.normalize('NFC', u): cwidth = unicodedata.east_asian_width(c) if cwidth in ('W', 'F'): w += 2 else: w += 1 return w
* Add iswide() and width() method for UserString according as theHye-Shik Chang2004-06-041-0/+25
| | | | addition to unicode objects.
* [SF #866875] Add a specialized routine for one characterHye-Shik Chang2004-01-051-14/+55
| | | | separaters on str.split() and str.rsplit().
* Fix unicode.rsplit()'s bug that ignores separater on the end of string whenHye-Shik Chang2003-12-231-0/+2
| | | | using specialized splitter for 1 char sep.
* Add rsplit method for str and unicode builtin types.Hye-Shik Chang2003-12-151-0/+20
| | | | | SF feature request #801847. Original patch is written by Sean Reifschneider.
* Add optional fillchar argument to ljust(), rjust(), and center() string methods.Raymond Hettinger2003-11-261-3/+3
|
* SF bug #795506: Wrong handling of string format code for float values.Raymond Hettinger2003-08-271-0/+1
| | | | | | Adding missing support for '%F'. Will backport to 2.3.1.
* Whitespace normalization.Tim Peters2003-04-241-1/+0
|
* Attempt to make all the various string *strip methods the same.Neal Norwitz2003-04-101-28/+27
| | | | | | | | | | | * 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.
* Fix PyString_Format() so that '%c' % u'a' returns u'a'Walter Dörwald2003-03-311-0/+1
| | | | | | | | instead of raising a TypeError. (From SF patch #710127) Add tests to verify this is fixed. Add various tests for '%c' % int.
* Add two tests for simple error cases.Walter Dörwald2003-03-261-0/+4
|
* Get test to work on alphaNeal Norwitz2003-02-231-1/+1
|