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: Bug in String rstrip method
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: dsm001, rcouplan, tim.peters
Priority: normal Keywords:

Created on 2005-01-19 00:58 by rcouplan, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg23978 - (view) Author: Rick Coupland (rcouplan) Date: 2005-01-19 00:58
There appears to be a data sensitive bug in the string rstrip 
method as demonstrated by the following code: 
 
>>> "ecigrcal.fle".rstrip(".fle") 
'ecigrca' 
 
As you can see, it is striping an extra character. 
msg23979 - (view) Author: DSM (dsm001) Date: 2005-01-19 01:51
Logged In: YES 
user_id=1175690

I don't think this is a bug.  The documentation for the
rstrip method reads:

rstrip(...)
    S.rstrip([chars]) -> string or unicode
    
    Return a copy of the string S with trailing whitespace
removed.
    If chars is given and not None, remove characters in
chars instead.

When you pass the method ".rle", you're telling it to treat
the four characters ".", "r", "l", and "e" as trailing
whitespace and remove them from the right side of the
string.  That's why it removes the extra "l".
msg23980 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2005-01-19 01:56
Logged In: YES 
user_id=31435

Yes, dsm001 is right.  The argument is treated as a _set_ of 
characters to be stripped, not as a literal string.  This is a 
natural generalization of .rstrip() without any characters, 
which chops off all whitespace characters (no matter how 
many there, and no matter what order they appear in).  
Passing an argument just changes the set of characters it 
deletes.
History
Date User Action Args
2022-04-11 14:56:09adminsetgithub: 41461
2005-01-19 00:58:34rcouplancreate