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

Fixers find, rfind, etc in 'string' module #47148

Closed
bhy mannequin opened this issue May 17, 2008 · 7 comments
Closed

Fixers find, rfind, etc in 'string' module #47148

bhy mannequin opened this issue May 17, 2008 · 7 comments
Labels
topic-2to3 type-feature A feature request or enhancement

Comments

@bhy
Copy link
Mannequin

bhy mannequin commented May 17, 2008

BPO 2899
Nosy @birkenfeld, @benjaminp, @mitsuhiko, @yaseppochi

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 2010-08-22.00:18:24.557>
created_at = <Date 2008-05-17.12:30:16.037>
labels = ['type-feature', 'expert-2to3']
title = "Fixers find, rfind, etc in 'string' module"
updated_at = <Date 2010-08-22.00:18:24.535>
user = 'https://bugs.python.org/bhy'

bugs.python.org fields:

activity = <Date 2010-08-22.00:18:24.535>
actor = 'georg.brandl'
assignee = 'none'
closed = True
closed_date = <Date 2010-08-22.00:18:24.557>
closer = 'georg.brandl'
components = ['2to3 (2.x to 3.x conversion tool)']
creation = <Date 2008-05-17.12:30:16.037>
creator = 'bhy'
dependencies = []
files = []
hgrepos = []
issue_num = 2899
keywords = []
message_count = 7.0
messages = ['66993', '77320', '77329', '77330', '81960', '81966', '114622']
nosy_count = 7.0
nosy_names = ['georg.brandl', 'collinwinter', 'benjamin.peterson', 'LambertDW', 'aronacher', 'bhy', 'sjt']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = None
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue2899'
versions = ['Python 3.0']

@bhy
Copy link
Mannequin Author

bhy mannequin commented May 17, 2008

Functions like find() rfind() index() rindex() has been removed in
Python 3.0. So there should be a 2to3 fix for it.

Eg. fix
if string.find(s, "hello") >= 0:
to
if str.find(s, "hello") >= 0:

Thank you!

@bhy bhy mannequin assigned collinwinter May 17, 2008
@bhy bhy mannequin added topic-2to3 type-feature A feature request or enhancement labels May 17, 2008
@benjaminp benjaminp changed the title Fixes find, rfind, etc in 'string' module Fixers find, rfind, etc in 'string' module May 17, 2008
@lambertdw
Copy link
Mannequin

lambertdw mannequin commented Dec 8, 2008

I expect the answer will be that 2to3 cannot know what sort of object
"string" names. Bell's theorem, or some such, as I understand it, tells
us that you must execute the algorithm to find out what it does, there
isn't a short cut.

It does seem like 2to3 could assume that you write code with honorable
intention, grace, and style and thereby offer a suggestive note. The
string module is not an isolated case for such notices. I made a
similar request to yours for "file" which is gone in version 3.

Unfortunately, code as follows is probably frequent, so we aren't likely
to get support for this feature. Maybe here is an opportunity for
venture capital!

def f(list):
    '''
        argument should be a list.
        "list" in this scope no longer names __builtins__.list
    '''

@mitsuhiko
Copy link
Member

2to3 could handle it, but it would be a lot of work for something
unnecessary. You can use "s.replace(a, b)" instead of string.replace(s,
a, b) since at least 2.0.

@lambertdw
Copy link
Mannequin

lambertdw mannequin commented Dec 8, 2008

I think the point is to get a message from 2to3 about possible use of
feature that is gone. Of course python3 raises an exception when trying
to execute the code, but it does leave the user wondering "why did 2to3
report that there are no changes necessary?".

@yaseppochi
Copy link
Mannequin

yaseppochi mannequin commented Feb 13, 2009

Maybe 2to3 could get a --pedantic or even an --annoying option? I agree
that it should be noisy about removed features even if actually fixing
this kind of thing would be hard to do reliably.

@benjaminp
Copy link
Contributor

I disagree. That is the role of -3 warnings. Static analysis is too
limited to get into issuing warnings with.

@birkenfeld
Copy link
Member

I guess this will not happen then.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-2to3 type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants