[New-bugs-announce] [issue13296] IDLE: __future__ flags don't clear on shell restart

Roger Serwy report at bugs.python.org
Sun Oct 30 18:24:51 CET 2011

New submission from Roger Serwy <roger.serwy at gmail.com>:

The interactive interpreter in IDLE does not reset its compiler __future__ flags when you restart the shell. 

To verify this, type into the shell:
    >>> from __future__ import barry_as_FLUFL
    >>> 1 != 2

You'll get a syntax error. Restart the shell and type

    >>> 1 != 2

A syntax error still occurs.

The ModifiedInterpreter class in PyShell.py ultimately relies on codeop to mimic the interactive prompt. The codeop module was created specifically for remembering __future__ flags for subsequent commands. 

The provided patch stores the flags of the interpreter when it first initializes, and then restores them in "restart_subprocess". It's a patch against 3.2.2.

components: IDLE
files: patch_future.diff
keywords: patch
messages: 146646
nosy: ezio.melotti, serwy
priority: normal
severity: normal
status: open
title: IDLE: __future__ flags don't clear on shell restart
type: behavior
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2
Added file: http://bugs.python.org/file23557/patch_future.diff

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list