classification
Title: IDLE - tabify/untabify applied when clicking Cancel
Type: behavior Stage: patch review
Components: IDLE Versions: Python 3.4, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: roger.serwy Nosy List: Todd.Rovito, asvetlov, python-dev, roger.serwy, serhiy.storchaka, terry.reedy
Priority: low Keywords: patch

Created on 2013-01-07 20:57 by roger.serwy, last changed 2013-04-07 01:33 by roger.serwy. This issue is now closed.

Files
File name Uploaded Description Edit
tabify.patch roger.serwy, 2013-01-07 20:57 review
Messages (6)
msg179282 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2013-01-07 20:57
Krystian RosiƄski notified me about an error with Tabify/Untabify. Clicking cancel still performs the operation because the _asktabwidth function in Lib/idlelib/EditorWindow.py always returns a number, regardless of cancel being clicked.

This bug is visibly noticeable with IdleX since it highlights all \t Tabs, but not with the original IDLE.

The attached patch solves the problem.
msg185622 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2013-03-31 08:55
If there are no objections, I will apply this patch after 2013-04-05.
msg185806 - (view) Author: Todd Rovito (Todd.Rovito) * Date: 2013-04-02 04:16
Roger,
  I tested the patch and it does seem to function as you describe so feel free to apply the patch.  The tabify function makes me scratch my head a little, according to help.txt:
"Tabify Region       -- Turns *leading* stretches of spaces into tabs
	(Note: We recommend using 4 space blocks to indent Python code.)"

Yet this code doesn't seem to get tabifyed.
a=[1,2,3,4,5]
for i in range(0, len(a)):
 print("%d" % a[i])

I would expect that the print statement be tabbed in but on my Mac it does not seem to do that it just puts back in the single space in front of the print.  This might be a separate issue but I was wondering if perhaps I misunderstand the purpose of this function?
msg185807 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2013-04-02 04:31
Todd,

Tabify/Untabify are functions to deal with the great tabs vs. spaces debate (though PEP8 says that spaces are the way to go). 

The tabify function needs a minimum of 2 spaces before it replaces it with a tab.

Its implementation in Lib/idlelib/EditorWindow.py under the tabify_region_event and untabify_region_event reveals a curiousity in its implementation. Tabify will replace spans of space characters with tabs, but still leave in extra space characters if needed. Untabify simply expands all tabs to a fixed number of spaces.
msg186173 - (view) Author: Roundup Robot (python-dev) Date: 2013-04-07 01:31
New changeset d7aa625147f7 by Roger Serwy in branch '2.7':
#16887: IDLE now accepts Cancel in tabify/untabify dialog box.
http://hg.python.org/cpython/rev/d7aa625147f7

New changeset 5451b82104f3 by Roger Serwy in branch '3.3':
#16887: IDLE now accepts Cancel in tabify/untabify dialog box.
http://hg.python.org/cpython/rev/5451b82104f3

New changeset 54f6d8c4dfaf by Roger Serwy in branch 'default':
#16887: merge with 3.3.
http://hg.python.org/cpython/rev/54f6d8c4dfaf
msg186174 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2013-04-07 01:33
Closing the issue as fixed.
History
Date User Action Args
2013-04-07 01:33:08roger.serwysetstatus: open -> closed
resolution: fixed
messages: + msg186174
2013-04-07 01:31:59python-devsetnosy: + python-dev
messages: + msg186173
2013-04-02 04:31:28roger.serwysetmessages: + msg185807
2013-04-02 04:16:05Todd.Rovitosetmessages: + msg185806
2013-03-31 17:00:47Todd.Rovitosetnosy: + Todd.Rovito
2013-03-31 08:55:56roger.serwysetassignee: roger.serwy
messages: + msg185622
versions: - Python 3.2
2013-01-14 22:02:21asvetlovsetnosy: + asvetlov
2013-01-12 01:44:56terry.reedysetnosy: + terry.reedy
2013-01-07 20:57:42roger.serwycreate