Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in String rstrip method #41461

Closed
rcouplan mannequin opened this issue Jan 19, 2005 · 3 comments
Closed

Bug in String rstrip method #41461

rcouplan mannequin opened this issue Jan 19, 2005 · 3 comments
Labels
stdlib Python modules in the Lib dir

Comments

@rcouplan
Copy link
Mannequin

rcouplan mannequin commented Jan 19, 2005

BPO 1104923
Nosy @tim-one

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2005-01-19.01:56:23.000>
created_at = <Date 2005-01-19.00:58:34.000>
labels = ['invalid', 'library']
title = 'Bug in String rstrip method'
updated_at = <Date 2005-01-19.01:56:23.000>
user = 'https://bugs.python.org/rcouplan'

bugs.python.org fields:

activity = <Date 2005-01-19.01:56:23.000>
actor = 'tim.peters'
assignee = 'none'
closed = True
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2005-01-19.00:58:34.000>
creator = 'rcouplan'
dependencies = []
files = []
hgrepos = []
issue_num = 1104923
keywords = []
message_count = 3.0
messages = ['23978', '23979', '23980']
nosy_count = 3.0
nosy_names = ['tim.peters', 'dsm001', 'rcouplan']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue1104923'
versions = []

@rcouplan
Copy link
Mannequin Author

rcouplan mannequin commented Jan 19, 2005

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.

@rcouplan rcouplan mannequin closed this as completed Jan 19, 2005
@rcouplan rcouplan mannequin added invalid stdlib Python modules in the Lib dir labels Jan 19, 2005
@rcouplan rcouplan mannequin closed this as completed Jan 19, 2005
@rcouplan rcouplan mannequin added invalid stdlib Python modules in the Lib dir labels Jan 19, 2005
@dsm001
Copy link
Mannequin

dsm001 mannequin commented Jan 19, 2005

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".

@tim-one
Copy link
Member

tim-one commented Jan 19, 2005

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.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

1 participant