Python interactive interpreter does not indent with tabs, tries to tab-complete

Bug #1315733 reported by Erik B. Andersen
28
This bug affects 6 people
Affects Status Importance Assigned to Milestone
python3.4 (Debian)
Fix Released
Unknown
python3.4 (Ubuntu)
Won't Fix
Undecided
Unassigned

Bug Description

Using the python3 interactive interpreter, I can not use tabs to indent like I could on previous versions of Ubuntu (13.10 was what I was using before, now I'm using 14.04).

When I try to indent on the python interpreter command line, it simply does nothing the first time I press the tab key. The second time I press it, it shows a bunch of autocomplete suggestions.

For example
>>> if (True):
... <tab>print("true!")
  File "<stdin>", line 2
    print("true!")
        ^
IndentationError: expected an indented block

Could this be related to http://bugs.python.org/issue18988? Is the fix for that included in the version of python on 14.04?

I also found http://stackoverflow.com/questions/4809820/tab-key-not-indenting-in-python, in which one of the comments to an answer suggests trying <Ctrl-V><tab> when you want to insert a tab. That does work for me:

>>> if (True):
... <Ctrl-V><tab>print("true")
...
true

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: python3 3.4.0-0ubuntu2
ProcVersionSignature: Ubuntu 3.13.0-24.46-generic 3.13.9
Uname: Linux 3.13.0-24-generic x86_64
NonfreeKernelModules: nvidia zfs zunicode zavl zcommon znvpair
ApportVersion: 2.14.1-0ubuntu3
Architecture: amd64
CurrentDesktop: Unity
Date: Sat May 3 11:36:57 2014
SourcePackage: python3-defaults
UpgradeStatus: Upgraded to trusty on 2014-04-19 (14 days ago)

Revision history for this message
Erik B. Andersen (erik-b-andersen+azendale) wrote :
tags: added: regression-release
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in python3-defaults (Ubuntu):
status: New → Confirmed
affects: python3-defaults (Ubuntu) → python3.4 (Ubuntu)
Revision history for this message
Matthias Klose (doko) wrote :

this is done by intent. see http://bugs.python.org/issue5845

to remove this behaviour, use this in sitecustomize or usercustomize:

    try:
        del sys.__interactivehook__
    except AttributeError:
        pass

Changed in python3.4 (Ubuntu):
status: Confirmed → Won't Fix
Revision history for this message
Erik B. Andersen (azendale) wrote :

Matthias, no, that was not apparently the intent, see the last two messages of that bug report:
http://bugs.python.org/issue5845#msg215784
The bug report was tracking multiple issues, and someone forgot about this one (and later said that they did, and said "should have gone back to being a release blocker after the alpha release to fix the tab-as-indent issue"). The intent of that bug report was to enable tab to complete, but also still allow tab in the interpreter as indentation (so a tab at the start of a (continuation) line would indent, and a tab after a non-whitespace character would complete).
They requested that this issue be raised in a new bugreport on the python bug tracker -- doing that now. Is it reasonable for me to set this bug back to confirmed?

Revision history for this message
Erik B. Andersen (azendale) wrote :

As requested in the upstream tracker, I've filed a bug in the upstream tracker: http://bugs.python.org/issue5845

Changed in python3.4 (Debian):
status: Unknown → Fix Released
Revision history for this message
Erik B. Andersen (azendale) wrote :

Oops, meant to include a different link in that last comment: http://bugs.python.org/issue22086

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.