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.
Created on 2011年10月27日 07:27 by ezio.melotti, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| string_partial.patch | superluser, 2014年09月09日 20:52 | review | ||
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 14835 | closed | aldwinaldwin, 2019年07月18日 08:34 | |
| Messages (5) | |||
|---|---|---|---|
| msg146475 - (view) | Author: Ezio Melotti (ezio.melotti) * (Python committer) | Date: 2011年10月27日 07:27 | |
$ cat deleteme.py from string import lowercase, uppercase, letters print uppercase == 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' print lowercase == 'abcdefghijklmnopqrstuvwxyz' print letters == 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' $ python deleteme.py True True True $ 2to3 -w deleteme.py RefactoringTool: Skipping implicit fixer: buffer RefactoringTool: Skipping implicit fixer: idioms RefactoringTool: Skipping implicit fixer: set_literal RefactoringTool: Skipping implicit fixer: ws_comma RefactoringTool: Refactored deleteme.py --- deleteme.py (original) +++ deleteme.py (refactored) @@ -1,4 +1,4 @@ from string import lowercase, uppercase, letters -print uppercase == 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' -print lowercase == 'abcdefghijklmnopqrstuvwxyz' -print letters == 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' +print(uppercase == 'ABCDEFGHIJKLMNOPQRSTUVWXYZ') +print(lowercase == 'abcdefghijklmnopqrstuvwxyz') +print(letters == 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') RefactoringTool: Files that were modified: RefactoringTool: deleteme.py $ python3 deleteme.py Traceback (most recent call last): File "deleteme.py", line 1, in <module> from string import lowercase, uppercase, letters ImportError: cannot import name lowercase They should be renamed to ascii_*. |
|||
| msg221808 - (view) | Author: Mark Lawrence (BreamoreBoy) * | Date: 2014年06月28日 18:22 | |
@Ezio can you prepare a patch for this? |
|||
| msg226659 - (view) | Author: Rose Ames (superluser) * | Date: 2014年09月09日 20:52 | |
Changing the imports only is straightforward, but I'm having trouble detecting and changing future uses of the variables, without also clobbering user-defined variables with the same names. I notice some of the current fixers have similar problems, for example the itertools fixer changes: ``` def imap(): pass imap() ``` to ``` def imap(): pass map() ``` This patch is a little smarter than that, but it only detects top-level definitions. For example, the lowercase in ``` class Foo: def __init__(self): self.lowercase = "blargh" ``` still gets renamed. I can work on this more, but would like to know: a) whether this fix is still wanted b) how smart it needs to be c) whether my approach is reasonable. I feel like there should be an easier way. |
|||
| msg226660 - (view) | Author: Rose Ames (superluser) * | Date: 2014年09月09日 20:55 | |
... d) how to format code :\ |
|||
| msg348107 - (view) | Author: Aldwin Pollefeyt (aldwinaldwin) * | Date: 2019年07月18日 08:42 | |
* there were many small issues with the patch, improved as good as possible the FixString to catch ```import as```, ```from string import *``` and ```import string``` * did not include the FixStringImports as it's not a necessity to work in Python3 * indeed, some uses of the constant names that are user-defined will also rename, only when it's in a ```import string```. Added a ```Caution``` in the documentation. Still, when all are changed, it should not affect the Python3 version, will just work with the renamed variable name. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:23 | admin | set | github: 57481 |
| 2021年10月20日 22:58:48 | iritkatriel | set | status: open -> closed superseder: Close 2to3 issues and list them here resolution: wont fix stage: patch review -> resolved |
| 2019年07月18日 08:42:25 | aldwinaldwin | set | nosy:
+ aldwinaldwin messages: + msg348107 |
| 2019年07月18日 08:34:06 | aldwinaldwin | set | stage: test needed -> patch review pull_requests: + pull_request14626 |
| 2019年04月26日 20:34:34 | BreamoreBoy | set | nosy:
- BreamoreBoy |
| 2014年09月09日 20:55:39 | superluser | set | messages: + msg226660 |
| 2014年09月09日 20:52:39 | superluser | set | files:
+ string_partial.patch nosy: + superluser messages: + msg226659 keywords: + patch |
| 2014年07月28日 02:53:49 | Anthony.Kong | set | nosy:
+ Anthony.Kong |
| 2014年06月28日 22:17:07 | ezio.melotti | set | keywords: + easy |
| 2014年06月28日 18:22:48 | BreamoreBoy | set | nosy:
+ BreamoreBoy messages: + msg221808 versions: + Python 3.4, Python 3.5, - Python 3.2, Python 3.3 |
| 2011年10月27日 14:07:22 | meador.inge | set | nosy:
+ meador.inge |
| 2011年10月27日 07:27:05 | ezio.melotti | create | |