Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 319496

Summary: Default settings for Indentation are wrong and will cause breakage
Product: [Technology] DLTK Reporter: Ben Wing <ben>
Component: PythonAssignee: dltk.python-inbox <dltk.python-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Ben Wing CLA 2010-07-11 20:27:27 EDT
Default settings for Indentation under Python->Editor are set as follows:

Tab policy: Tabs only
Indentation size: 4
Displayed tab size: 4

These settings are completely wrong for Python and are likely to cause breakage:

(1) Python programs should probably not use tabs at all.
(2) When tabs are used, Python treats them as 8 spaces, not 4.
(3) If I edit existing Python code with Eclipse, I will probably cause things to break, even though the file appears fine in Eclipse.  E.g. say I have a file with this in it:

def foo(a, b):
    do_something()
    do_something_else()

If this is legitimate Python code, the indentation of the two lines in function foo() will have spaces.  If I now open this file in Eclipse, and add new code at the beginning of the function:

def foo(a, b):
    do_this_first()
    do_something()
    do_something_else()

Eclipse will indent the line with do_this_first() using a single Tab character, which it displays using 4 spaces.  The code *looks* fine in Eclipse, but if run, you get an error:

    do_something()
                 ^
IndentationError: unindent does not match any outer indentation level

This is extremely hostile behavior.  The defaults should be changed:

Tab policy: Spaces only
Indentation size: 4
Displayed tab size: 8

This way, tabs are correctly displayed with 8 spaces, not 4, and indentation will purely use spaces.

Note that if you mix tabs and spaces if Python 3, you will get an error, even if you match up indentation:

        do_something()
                     ^
TabError: inconsistent use of tabs and spaces in indentation
Comment 1 Dawid Pakula CLA 2020-01-03 07:54:26 EST
Python support has been removed