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: string.strip implementation/doc mismatch
Type: Stage:
Components: Documentation Versions: Python 2.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: nnorwitz Nosy List: doerwalter, ghaering, nnorwitz
Priority: normal Keywords:

Created on 2003-03-04 12:48 by ghaering, last changed 2022-04-10 16:07 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
strip.diff nnorwitz, 2003-03-06 06:23 patch for 2.3 to harmonize all the string/unicode strips
strip2.2.diff nnorwitz, 2003-03-19 01:41 patch for 2.2.3 to harmonize all the string/unicode strips
strip.diff nnorwitz, 2003-03-30 19:54 2.3 patch 2
strip2.2.diff nnorwitz, 2003-03-30 20:05 2.2 patch 2
strip.diff doerwalter, 2003-04-02 19:39 2.3 patch 3
strip-2.2.diff doerwalter, 2003-04-02 19:40 2.2 patch 3
Messages (10)
msg14930 - (view) Author: Gerhard Häring (ghaering) * (Python committer) Date: 2003-03-04 12:48
#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.
msg14931 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-03-04 17:55
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
msg14932 - (view) Author: Gerhard Häring (ghaering) * (Python committer) Date: 2003-03-04 18:10
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.
msg14933 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-03-04 18:20
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.
msg14934 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-03-06 06:25
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.
msg14935 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2003-03-20 11:36
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.
msg14936 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-03-30 19:54
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.
msg14937 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2003-04-02 19:39
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.
msg14938 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-04-10 22:59
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.
msg14939 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-04-11 18:40
Logged In: YES 
user_id=33168

I hope this is the end of this mistake.  Let me know if
there's any other inconsistencies.  Thanks for the review
Walter!

Checked in as:
 Misc/NEWS: 1.337.2.4.2.73
 Doc/lib/libstring.tex: 1.45.8.5
 Lib/UserString.py: 1.10.18.3
 Lib/string.py: 1.60.16.5
 Objects/stringobject.c: 2.147.6.13
 Objects/unicodeobject.c: 2.124.6.21
History
Date User Action Args
2022-04-10 16:07:19adminsetgithub: 38093
2003-03-04 12:48:37ghaeringcreate