[Python-checkins] cpython: Issue #14958: Change IDLE systax highlighting to recognize all string and

ned.deily python-checkins at python.org
Wed May 30 07:56:52 CEST 2012


http://hg.python.org/cpython/rev/94a5bf416e50
changeset:   77242:94a5bf416e50
user:        Ned Deily <nad at acm.org>
date:        Tue May 29 22:55:43 2012 -0700
summary:
  Issue #14958: Change IDLE systax highlighting to recognize all string and
byte literals supported in Python 3.3.

files:
  Lib/idlelib/ColorDelegator.py |  9 +++++----
  Misc/NEWS                     |  3 +++
  2 files changed, 8 insertions(+), 4 deletions(-)


diff --git a/Lib/idlelib/ColorDelegator.py b/Lib/idlelib/ColorDelegator.py
--- a/Lib/idlelib/ColorDelegator.py
+++ b/Lib/idlelib/ColorDelegator.py
@@ -21,10 +21,11 @@
     # 1st 'file' colorized normal, 2nd as builtin, 3rd as string
     builtin = r"([^.'\"\\#]\b|^)" + any("BUILTIN", builtinlist) + r"\b"
     comment = any("COMMENT", [r"#[^\n]*"])
-    sqstring = r"(\b[rRbB])?'[^'\\\n]*(\\.[^'\\\n]*)*'?"
-    dqstring = r'(\b[rRbB])?"[^"\\\n]*(\\.[^"\\\n]*)*"?'
-    sq3string = r"(\b[rRbB])?'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?"
-    dq3string = r'(\b[rRbB])?"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?'
+    stringprefix = r"(\br|u|ur|R|U|UR|Ur|uR|b|B|br|Br|bR|BR|rb|rB|Rb|RB)?"
+    sqstring = stringprefix + r"'[^'\\\n]*(\\.[^'\\\n]*)*'?"
+    dqstring = stringprefix + r'"[^"\\\n]*(\\.[^"\\\n]*)*"?'
+    sq3string = stringprefix + r"'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?"
+    dq3string = stringprefix + r'"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?'
     string = any("STRING", [sq3string, dq3string, sqstring, dqstring])
     return kw + "|" + builtin + "|" + comment + "|" + string +\
            "|" + any("SYNC", [r"\n"])
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -60,6 +60,9 @@
 Library
 -------
 
+- Issue #14958: Change IDLE systax highlighting to recognize all string and
+  byte literals supported in Python 3.3.
+
 - Issue #10997: Prevent a duplicate entry in IDLE's "Recent Files" menu.
 
 - Issue #14443: Tell rpmbuild to use the correct version of Python in

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list