[Patches] [ python-Patches-591250 ] str1 in str2

noreply@sourceforge.net noreply@sourceforge.net
Tue, 06 Aug 2002 09:47:24 -0700


Patches item #591250, was opened at 2002-08-05 15:09
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=591250&group_id=5470

Category: Core (C code)
Group: Python 2.3
Status: Open
>Resolution: Accepted
Priority: 5
Submitted By: Neal Norwitz (nnorwitz)
>Assigned to: Barry A. Warsaw (bwarsaw)
>Summary: str1 in str2

Initial Comment:
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.

----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-08-06 12:47

Message:
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.

----------------------------------------------------------------------

Comment By: Barry A. Warsaw (bwarsaw)
Date: 2002-08-06 12:08

Message:
Logged In: YES 
user_id=12800

Oops, assigning to Guido.

----------------------------------------------------------------------

Comment By: Barry A. Warsaw (bwarsaw)
Date: 2002-08-06 12:08

Message:
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.


----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2002-08-05 20:43

Message:
Logged In: YES 
user_id=33168

test_contains.py checks for multi-char strings using in.  I
attached a patch that removes these checks.

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2002-08-05 20:06

Message:
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)?

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2002-08-05 17:01

Message:
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?

----------------------------------------------------------------------

Comment By: Barry A. Warsaw (bwarsaw)
Date: 2002-08-05 16:55

Message:
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.

----------------------------------------------------------------------

Comment By: Barry A. Warsaw (bwarsaw)
Date: 2002-08-05 16:50

Message:
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.


----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2002-08-05 15:39

Message:
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?

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2002-08-05 15:17

Message:
Logged In: YES 
user_id=6380

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

Does this do Unicode?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=591250&group_id=5470