From 40e95dfcaafb71a195e5e3bd26f5a832edb34446 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sat, 29 Mar 2014 21:01:50 -0700 Subject: [PATCH] Issue #21029: IDLE now colors print consistently as a keyword. --- Lib/idlelib/ColorDelegator.py | 3 +++ Misc/NEWS | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/Lib/idlelib/ColorDelegator.py b/Lib/idlelib/ColorDelegator.py index c74865d4fb..4838c44c8c 100644 --- a/Lib/idlelib/ColorDelegator.py +++ b/Lib/idlelib/ColorDelegator.py @@ -16,6 +16,9 @@ def make_pat(): kw = r"\b" + any("KEYWORD", keyword.kwlist) + r"\b" builtinlist = [str(name) for name in dir(__builtin__) if not name.startswith('_')] + # We don't know whether "print" is a function or a keyword, + # so we always treat is as a keyword (the most common case). + builtinlist.remove('print') # self.file = file("file") : # 1st 'file' colorized normal, 2nd as builtin, 3rd as string builtin = r"([^.'\"\\#]\b|^)" + any("BUILTIN", builtinlist) + r"\b" diff --git a/Misc/NEWS b/Misc/NEWS index d08d0c1d6a..49dbe53e13 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -265,6 +265,10 @@ IDLE - Issue #20406: Use Python application icons for Idle window title bars. Patch mostly by Serhiy Storchaka. +- Issue #21029: Occurrences of "print" are now consistently colored as + being a keyword (the colorizer doesn't know if print functions are + enabled in the source). + - Issue #17721: Remove non-functional configuration dialog help button until we make it actually gives some help when clicked. Patch by Guilherme Simões. -- 2.50.1