[Python-bugs-list] [ python-Bugs-697220 ] string.strip implementation/doc mismatch

SourceForge.net noreply@sourceforge.net
Thu, 10 Apr 2003 15:59:53 -0700


Bugs item #697220, was opened at 2003-03-04 07:48
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=697220&group_id=5470

Category: Documentation
Group: Python 2.2.2
Status: Open
Resolution: Fixed
Priority: 5
Submitted By: Gerhard Häring (ghaering)
Assigned to: Neal Norwitz (nnorwitz)
Summary: string.strip implementation/doc mismatch

Initial Comment:
#v+
>>> "test".strip("t")
'es'
>>> import string
>>> print string.strip("test", "t")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: strip() takes exactly 1 argument (2 given)
>>>
#v-

*But* the Python documentation says that not only the
string *method* strip() will allow a second optional
argument, but also the strip function in the string
module.
(http://www.python.org/doc/current/lib/module-string.html)

string.strip should be changed to accept the additional
 parameter.

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

>Comment By: Neal Norwitz (nnorwitz)
Date: 2003-04-10 18:59

Message:
Logged In: YES 
user_id=33168

Checked in as (updated doc slightly from Walter's patch):
 Doc/lib/libstring.tex: 1.49
 Lib/UserString.py: 1.17
 Lib/string.py: 1.68
 Lib/test/string_tests.py: 1.31
 Objects/stringobject.c: 2.208
 Objects/unicodeobject.c: 2.187

Will close after backporting changes.

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

Comment By: Walter Dörwald (doerwalter)
Date: 2003-04-02 14:39

Message:
Logged In: YES 
user_id=89016

Here are updated patches: I've renamed the arguments from
sep to chars in UserString too and I've added the
"versionchanged" info to all three functions in both patches.

I think the patches are ready now.

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

Comment By: Neal Norwitz (nnorwitz)
Date: 2003-03-30 14:54

Message:
Logged In: YES 
user_id=33168

Updated both patches to fix problem with sep--changed
docstrings to use chars.  Updated string_tests for 2.3.

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

Comment By: Walter Dörwald (doerwalter)
Date: 2003-03-20 06:36

Message:
Logged In: YES 
user_id=89016

In the patch for 2.3 a few docstrings in string.py still
mention sep instead of chars. The tests in
test/string_tests.py::MixinStrUnicodeUserStringTest.test_strip_args()
should be moved to CommonTest.test_strip() so that these
tests will be run for the string module too.

I haven't looked at the 2.2.3 patch yet.

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

Comment By: Neal Norwitz (nnorwitz)
Date: 2003-03-06 01:25

Message:
Logged In: YES 
user_id=33168

Gerhard, hopefully I've cleaned things up this time.  Could
you review both patches attached (one for 2.2.3, the other
for 2.3)?  I will send a message to python-dev to get
concurrence on the changes and hopefully more review.

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

Comment By: Neal Norwitz (nnorwitz)
Date: 2003-03-04 13:20

Message:
Logged In: YES 
user_id=33168

Thanks, you are correct.  The problem was with the string
object, not the string module.  :-(  I need to look at this
more.

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

Comment By: Gerhard Häring (ghaering)
Date: 2003-03-04 13:10

Message:
Logged In: YES 
user_id=163326

Neil, I don't think this was implemented in the 2.2
maintenance branch. That's why I'm reopening this. At least
for my 2.2 Pythons string.strip accepts one parameter only:

Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more
information.
>>> import string
>>> string.strip("test", "t")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: strip() takes exactly 1 argument (2 given)
>>>

and

Python 2.2.2 (#1, Feb  9 2003, 13:22:07)
[GCC 3.2.1 [FreeBSD] 20021119 (release)] on freebsd5
Type "help", "copyright", "credits" or "license" for more
information.
>>> import string
>>> string.strip("test", "t")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: strip() takes exactly 1 argument (2 given)

Confused.

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

Comment By: Neal Norwitz (nnorwitz)
Date: 2003-03-04 12:55

Message:
Logged In: YES 
user_id=33168

Gerhard, 2.2.2 does have 2 arguments, but 2.2.1 and before
do not.  We should really update the doc.  I thought this
was done, but apparently not.

Checked in as: libstring.tex 1.45.8.4

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

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