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: lib2to3 fails to convert 'thread' when not followed by a period
Type: behavior Stage: test needed
Components: 2to3 (2.x to 3.x conversion tool) Versions: Python 2.6
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, ericp
Priority: normal Keywords:

Created on 2009-07-17 17:54 by ericp, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg90635 - (view) Author: Eric Promislow (ericp) Date: 2009-07-17 17:54
Given this code:

import thread
print thread

$ python
ActivePython 2.6.1.1 (ActiveState Software Inc.) based on
Python 2.6.1 (r261:67515, Dec  5 2008, 13:58:38) [MSC v.1500 32 bit
(Intel)] on
win32
>>> from lib2to3.main import main
>>> print open("flip2.py").read()
import thread
print thread

>>> main('lib2to3.fixes', ['flip2.py'])
RefactoringTool: Skipping implicit fixer: buffer
RefactoringTool: Skipping implicit fixer: idioms
RefactoringTool: Skipping implicit fixer: set_literal
RefactoringTool: Skipping implicit fixer: ws_comma
--- flip2.py (original)
+++ flip2.py (refactored)
@@ -1,2 +1,2 @@
-import thread
-print thread
+import _thread
+print(thread)
RefactoringTool: Files that need to be modified:
RefactoringTool: flip2.py
0

Note how "thread" in the print statement is not converted.
msg90636 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-07-17 18:58
This is purposeful. Otherwise random variables, functions, or classes,
with the same name as a module which people were using could be changed.
msg90638 - (view) Author: Eric Promislow (ericp) Date: 2009-07-17 19:14
Understood.  Could the tool emit a warning when it encounters
something like this?
msg90639 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-07-17 19:21
2009/7/17 Eric Promislow <report@bugs.python.org>:
>
> Eric Promislow <ericp@activestate.com> added the comment:
>
> Understood.  Could the tool emit a warning when it encounters
> something like this?

Perhaps, but I think you could find this out just as well by running a
tool like Pylint over your code.
History
Date User Action Args
2022-04-11 14:56:51adminsetgithub: 50755
2009-07-17 19:22:30benjamin.petersonsetstatus: open -> closed
resolution: wont fix
2009-07-17 19:21:11benjamin.petersonsetmessages: + msg90639
2009-07-17 19:14:53ericpsetmessages: + msg90638
2009-07-17 18:58:11benjamin.petersonsetmessages: + msg90636
2009-07-17 18:49:49r.david.murraysetpriority: normal
nosy: + benjamin.peterson

stage: test needed
2009-07-17 17:54:18ericpcreate