Mailing List Archive

[issue5129] indentation in IDLE 2.6 different from IDLE 2.5, 2.4 or vim
New submission from sy12 <sy12@club-internet.fr>:

platform: Windows XP

In a file (cf attached file) with mixed tabs and spaces, the line
following "else:" appears at the same level than "else:", while the file
probably still works with Python 2.6. At least, IDLE 2.5 or IDLE 2.4 or
vim don't have this problem.

----------
components: IDLE
files: bug.py
messages: 80941
nosy: sy12
severity: normal
status: open
title: indentation in IDLE 2.6 different from IDLE 2.5, 2.4 or vim
type: behavior
versions: Python 2.6
Added file: http://bugs.python.org/file12918/bug.py

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue5129>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue5129] indentation in IDLE 2.6 different from IDLE 2.5, 2.4 or vim [ In reply to ]
sy12 <sy12@club-internet.fr> added the comment:

IDLE's "untabify" feature (required by IDLE 2.6 when running from IDLE)
seems to do the job correctly but this function doesn't inspire trust
and might damage the code, because IDLE 2.6 is not able to correctly
display mixed spaces and tabs (maybe for a reason linked to python 3 but
I didn't find it in the logs, so maybe it's just a bug) and because of
the default value given by the dialog, quite frightening: 4 spaces for a
tab, instead of 8. By giving 8 the problem seems to be solved, even for
IDLE 2.6.

Maybe IDLE 2.6 is assuming by default that a tab is 4 spaces?

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue5129>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue5129] indentation in IDLE 2.6 different from IDLE 2.5, 2.4 or vim [ In reply to ]
Raymond Hettinger <rhettinger@users.sourceforge.net> added the comment:

I don't see a problem with Untabify. IDLE cannot know how big you
intended your tabs to be, so it presents a dialog asking you. That
seems reasonable to me.

In most cases, the default is pretty good -- it attempts to infer the
tab width by finding the first manual indentation using spaces:

'if:\n pass\nif:\n\tpass\n' --> guesses a two space indent

What differences are you seeing between 2.5 and 2.6? Is it the initial
display is different, is the untabify default different, or what?

----------
nosy: +rhettinger

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue5129>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue5129] indentation in IDLE 2.6 different from IDLE 2.5, 2.4 or vim [ In reply to ]
sy12 <sy12@club-internet.fr> added the comment:

The problem appeared in the initial display, with a file similar to bug.py.

Here is how to reproduce it:
1. open the bug.py file with IDLE 2.5 (or with Firefox from the
bugs.python.org website): the display shows the file the way the
compiler will (probably) see it;
2. open the bug.py file with IDLE 2.6: the line 7 (just after "else:")
is displayed differently.

Summary: IDLE 2.6 doesn't display the indentation that the compiler will
see.

-----------------------------------------
About the secondary problem with Untabify (discovered when trying to
solve the display problem without having to reinstall Python 2.5):

Actually, Untabify is more a solution than a problem, except maybe that
the only safe value is 8 spaces for a tabulation. Using a different
value on legacy code (old code without tests) might add subtle bugs.

According to the Python Language Reference:
"First, tabs are replaced (from left to right) by one to eight spaces
such that the total number of characters up to and including the
replacement is a multiple of eight (this is intended to be the same rule
as used by Unix)."
-----------------------------------------

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue5129>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue5129] indentation in IDLE 2.6 different from IDLE 2.5, 2.4 or vim [ In reply to ]
Changes by Raymond Hettinger <rhettinger@users.sourceforge.net>:


----------
assignee: -> kbk
nosy: +kbk
priority: -> high

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue5129>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com