This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: str1 in str2
Type: Stage:
Components: Interpreter Core Versions: Python 2.3
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: barry Nosy List: barry, gvanrossum, nnorwitz
Priority: normal Keywords: patch

Created on 2002-08-05 19:09 by nnorwitz, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
contains.diff nnorwitz, 2002-08-05 19:39 contains patch 2
contains2.diff barry, 2002-08-05 20:50
contains-test.diff nnorwitz, 2002-08-06 00:43 test_contains.py patch
mondo-contains.diff barry, 2002-08-06 16:08
Messages (12)
msg40836 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2002-08-05 19:09
Here's a patch to implement and test str1 in str2, when
str1 is more than a single character.
The doc and unicode still need to be updated.  There is
a test.
msg40837 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-08-05 19:17
Logged In: YES 
user_id=6380

Let Barry collect the patches. (He sent one in private email
too.)

Does this do Unicode?
msg40838 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2002-08-05 19:39
Logged In: YES 
user_id=33168

Went a little further.  Add unicode support.  Where should
the string/unicode tests go?
string tests are in string_tests.py now, but not sure that
is appropriate.

Still needs:
 * unicode test
 * doc - where?
msg40839 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2002-08-05 20:50
Logged In: YES 
user_id=12800

There were some problems with this patch.  test_unicode.py
already contains <wink> some contains tests, which fail with
your patch.  This fixes them at the expense of not
special-casing contains with a single character (in unicode
only -- normal strings still have the special case).  

This version of the patch also adds some more tests.  I
think the only thing left to do is update the docs.
msg40840 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2002-08-05 20:55
Logged In: YES 
user_id=12800

I actually think Fred should get in on the act because it's
not clear to me where in the docs this should be documented.
 Assigning to Fred for an answer, then he can re-assign back
to me.
msg40841 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-08-05 21:01
Logged In: YES 
user_id=6380

I'm still at best -0 on the exception for empty left
argument. Fortunately we can easily change that (I'm
guessing it's just a matter of removing some code :-) if I
don't change my mind.

And the special case for 1-char Unicode should probably be
restored.

Can someone please mail the other person who posted a
pointer to a patch to python-dev, to avoid him doing more
work on cleaning up his patch?
msg40842 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2002-08-06 00:06
Logged In: YES 
user_id=33168

I'm not sure what PyUnicode_GET_SIZE() returns if using
UCS-2 or UCS-4.  Does size need to be size *= sizeof(*lhs),
ie size *= sizeof(Py_UNICODE)?
msg40843 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2002-08-06 00:43
Logged In: YES 
user_id=33168

test_contains.py checks for multi-char strings using in.  I
attached a patch that removes these checks.
msg40844 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2002-08-06 16:08
Logged In: YES 
user_id=12800

Attached is the entire patch ready for pronouncement.  This
one merges Neal's test_contains.py patch and contains2.diff.
 It also restores the 1-char unicode check, includes a doc
patch, and implements Guido's current leanings towards '' in
'str' returning True.

Assign to Guido for pronouncement.
msg40845 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2002-08-06 16:08
Logged In: YES 
user_id=12800

Oops, assigning to Guido.
msg40846 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-08-06 16:47
Logged In: YES 
user_id=6380

OK, accepted. Please get rid of the #if 0 business and a few
##commented-out items and idle use of my name; then check it in.
msg40847 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2002-08-06 16:58
Logged In: YES 
user_id=12800

Committed to cvs.
History
Date User Action Args
2022-04-10 16:05:33adminsetgithub: 36984
2002-08-05 19:09:36nnorwitzcreate