summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2016-09-08 17:59:53 (GMT)
committerR David Murray <rdmurray@bitdance.com>2016-09-08 17:59:53 (GMT)
commit44b548dda872c0d4f30afd6b44fd74b053a55ad8 (patch)
treeb3c1ff8485bc279000f9db95491ebc69a4385876 /Tools
parent513d7478a136e7646075592da2593476299cc8be (diff)
downloadcpython-44b548dda872c0d4f30afd6b44fd74b053a55ad8.zip
cpython-44b548dda872c0d4f30afd6b44fd74b053a55ad8.tar.gz
cpython-44b548dda872c0d4f30afd6b44fd74b053a55ad8.tar.bz2
#27364: fix "incorrect" uses of escape character in the stdlib.
And most of the tools. Patch by Emanual Barry, reviewed by me, Serhiy Storchaka, and Martin Panter.
Diffstat (limited to 'Tools')
-rwxr-xr-xTools/clinic/clinic.py2
-rwxr-xr-xTools/demo/ss1.py2
-rw-r--r--Tools/freeze/winmakemakefile.py6
-rw-r--r--Tools/pybench/CommandLine.py4
-rw-r--r--Tools/pynche/ColorDB.py6
-rwxr-xr-xTools/scripts/fixdiv.py4
-rwxr-xr-xTools/scripts/h2py.py8
-rwxr-xr-xTools/scripts/highlight.py16
-rwxr-xr-xTools/scripts/mailerdaemon.py2
-rwxr-xr-xTools/scripts/parseentities.py4
-rwxr-xr-xTools/scripts/pathfix.py2
-rwxr-xr-xTools/scripts/ptags.py2
-rwxr-xr-xTools/scripts/svneol.py2
-rwxr-xr-xTools/scripts/texi2html.py10
-rw-r--r--Tools/unicode/gencodec.py10
15 files changed, 40 insertions, 40 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index f583fc5..afd1a5f 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -1222,7 +1222,7 @@ def OverrideStdioWith(stdout):
def create_regex(before, after, word=True, whole_line=True):
"""Create an re object for matching marker lines."""
- group_re = "\w+" if word else ".+"
+ group_re = r"\w+" if word else ".+"
pattern = r'{}({}){}'
if whole_line:
pattern = '^' + pattern + '$'
diff --git a/Tools/demo/ss1.py b/Tools/demo/ss1.py
index c51f041..bf88820 100755
--- a/Tools/demo/ss1.py
+++ b/Tools/demo/ss1.py
@@ -413,7 +413,7 @@ class FormulaCell(BaseCell):
def renumber(self, x1, y1, x2, y2, dx, dy):
out = []
- for part in re.split('(\w+)', self.formula):
+ for part in re.split(r'(\w+)', self.formula):
m = re.match('^([A-Z]+)([1-9][0-9]*)$', part)
if m is not None:
sx, sy = m.groups()
diff --git a/Tools/freeze/winmakemakefile.py b/Tools/freeze/winmakemakefile.py
index 3843388..439a1d7 100644
--- a/Tools/freeze/winmakemakefile.py
+++ b/Tools/freeze/winmakemakefile.py
@@ -95,7 +95,7 @@ def realwork(vars, moddefns, target):
print()
print('$(temp_dir):')
- print(' if not exist $(temp_dir)\. mkdir $(temp_dir)')
+ print(r' if not exist $(temp_dir)\. mkdir $(temp_dir)')
print()
objects = []
@@ -106,7 +106,7 @@ def realwork(vars, moddefns, target):
base = os.path.basename(file)
base, ext = os.path.splitext(base)
objects.append(base + ".obj")
- print('$(temp_dir)\%s.obj: "%s"' % (base, file))
+ print(r'$(temp_dir)\%s.obj: "%s"' % (base, file))
print("\t@$(CC) -c -nologo /Fo$* $(cdl) $(c_debug) /D BUILD_FREEZE", end=' ')
print('"-I$(pythonhome)/Include" "-I$(pythonhome)/PC" \\')
print("\t\t$(cflags) $(cdebug) $(cinclude) \\")
@@ -126,7 +126,7 @@ def realwork(vars, moddefns, target):
print() ; print()
print("OBJS=", end=' ')
- for obj in objects: print('"$(temp_dir)\%s"' % (obj), end=' ')
+ for obj in objects: print(r'"$(temp_dir)\%s"' % (obj), end=' ')
print() ; print()
print("LIBS=", end=' ')
diff --git a/Tools/pybench/CommandLine.py b/Tools/pybench/CommandLine.py
index 073cca0..54a8ba7 100644
--- a/Tools/pybench/CommandLine.py
+++ b/Tools/pybench/CommandLine.py
@@ -99,8 +99,8 @@ def option_dict(options):
# Alias
getpasswd = invisible_input
-_integerRE = re.compile('\s*(-?\d+)\s*$')
-_integerRangeRE = re.compile('\s*(-?\d+)\s*-\s*(-?\d+)\s*$')
+_integerRE = re.compile(r'\s*(-?\d+)\s*$')
+_integerRangeRE = re.compile(r'\s*(-?\d+)\s*-\s*(-?\d+)\s*$')
def srange(s,
diff --git a/Tools/pynche/ColorDB.py b/Tools/pynche/ColorDB.py
index 5ced0e7..0348148 100644
--- a/Tools/pynche/ColorDB.py
+++ b/Tools/pynche/ColorDB.py
@@ -134,17 +134,17 @@ class ColorDB:
class RGBColorDB(ColorDB):
_re = re.compile(
- '\s*(?P<red>\d+)\s+(?P<green>\d+)\s+(?P<blue>\d+)\s+(?P<name>.*)')
+ r'\s*(?P<red>\d+)\s+(?P<green>\d+)\s+(?P<blue>\d+)\s+(?P<name>.*)')
class HTML40DB(ColorDB):
- _re = re.compile('(?P<name>\S+)\s+(?P<hexrgb>#[0-9a-fA-F]{6})')
+ _re = re.compile(r'(?P<name>\S+)\s+(?P<hexrgb>#[0-9a-fA-F]{6})')
def _extractrgb(self, mo):
return rrggbb_to_triplet(mo.group('hexrgb'))
class LightlinkDB(HTML40DB):
- _re = re.compile('(?P<name>(.+))\s+(?P<hexrgb>#[0-9a-fA-F]{6})')
+ _re = re.compile(r'(?P<name>(.+))\s+(?P<hexrgb>#[0-9a-fA-F]{6})')
def _extractname(self, mo):
return mo.group('name').strip()
diff --git a/Tools/scripts/fixdiv.py b/Tools/scripts/fixdiv.py
index 20f3386..1213a4e 100755
--- a/Tools/scripts/fixdiv.py
+++ b/Tools/scripts/fixdiv.py
@@ -174,8 +174,8 @@ def usage(msg):
sys.stderr.write("Usage: %s [-m] warnings\n" % sys.argv[0])
sys.stderr.write("Try `%s -h' for more information.\n" % sys.argv[0])
-PATTERN = ("^(.+?):(\d+): DeprecationWarning: "
- "classic (int|long|float|complex) division$")
+PATTERN = (r"^(.+?):(\d+): DeprecationWarning: "
+ r"classic (int|long|float|complex) division$")
def readwarnings(warningsfile):
prog = re.compile(PATTERN)
diff --git a/Tools/scripts/h2py.py b/Tools/scripts/h2py.py
index 0967fc2..4363c0c 100755
--- a/Tools/scripts/h2py.py
+++ b/Tools/scripts/h2py.py
@@ -23,13 +23,13 @@
import sys, re, getopt, os
-p_define = re.compile('^[\t ]*#[\t ]*define[\t ]+([a-zA-Z0-9_]+)[\t ]+')
+p_define = re.compile(r'^[\t ]*#[\t ]*define[\t ]+([a-zA-Z0-9_]+)[\t ]+')
p_macro = re.compile(
- '^[\t ]*#[\t ]*define[\t ]+'
- '([a-zA-Z0-9_]+)\(([_a-zA-Z][_a-zA-Z0-9]*)\)[\t ]+')
+ r'^[\t ]*#[\t ]*define[\t ]+'
+ r'([a-zA-Z0-9_]+)\(([_a-zA-Z][_a-zA-Z0-9]*)\)[\t ]+')
-p_include = re.compile('^[\t ]*#[\t ]*include[\t ]+<([^>\n]+)>')
+p_include = re.compile(r'^[\t ]*#[\t ]*include[\t ]+<([^>\n]+)>')
p_comment = re.compile(r'/\*([^*]+|\*+[^/])*(\*+/)?')
p_cpp_comment = re.compile('//.*')
diff --git a/Tools/scripts/highlight.py b/Tools/scripts/highlight.py
index 66ad868..9272fee 100755
--- a/Tools/scripts/highlight.py
+++ b/Tools/scripts/highlight.py
@@ -147,14 +147,14 @@ def build_html_page(classified_text, title='python',
#### LaTeX Output ##########################################
default_latex_commands = {
- 'comment': '{\color{red}#1}',
- 'string': '{\color{ForestGreen}#1}',
- 'docstring': '{\emph{\color{ForestGreen}#1}}',
- 'keyword': '{\color{orange}#1}',
- 'builtin': '{\color{purple}#1}',
- 'definition': '{\color{orange}#1}',
- 'defname': '{\color{blue}#1}',
- 'operator': '{\color{brown}#1}',
+ 'comment': r'{\color{red}#1}',
+ 'string': r'{\color{ForestGreen}#1}',
+ 'docstring': r'{\emph{\color{ForestGreen}#1}}',
+ 'keyword': r'{\color{orange}#1}',
+ 'builtin': r'{\color{purple}#1}',
+ 'definition': r'{\color{orange}#1}',
+ 'defname': r'{\color{blue}#1}',
+ 'operator': r'{\color{brown}#1}',
}
default_latex_document = r'''
diff --git a/Tools/scripts/mailerdaemon.py b/Tools/scripts/mailerdaemon.py
index aeb451e..635e548 100755
--- a/Tools/scripts/mailerdaemon.py
+++ b/Tools/scripts/mailerdaemon.py
@@ -88,7 +88,7 @@ del i
# no more expressions are searched for. So, order is important.
emparse_list_reason = [
r'^5\d{2} <>\.\.\. (?P<reason>.*)',
- '<>\.\.\. (?P<reason>.*)',
+ r'<>\.\.\. (?P<reason>.*)',
re.compile(r'^<<< 5\d{2} (?P<reason>.*)', re.MULTILINE),
re.compile('===== stderr was =====\nrmail: (?P<reason>.*)'),
re.compile('^Diagnostic-Code: (?P<reason>.*)', re.MULTILINE),
diff --git a/Tools/scripts/parseentities.py b/Tools/scripts/parseentities.py
index a042d1c..c686b02 100755
--- a/Tools/scripts/parseentities.py
+++ b/Tools/scripts/parseentities.py
@@ -14,7 +14,7 @@
"""
import re,sys
-entityRE = re.compile('<!ENTITY +(\w+) +CDATA +"([^"]+)" +-- +((?:.|\n)+?) *-->')
+entityRE = re.compile(r'<!ENTITY +(\w+) +CDATA +"([^"]+)" +-- +((?:.|\n)+?) *-->')
def parse(text,pos=0,endpos=None):
@@ -39,7 +39,7 @@ def writefile(f,defs):
if charcode[:2] == '&#':
code = int(charcode[2:-1])
if code < 256:
- charcode = "'\%o'" % code
+ charcode = r"'\%o'" % code
else:
charcode = repr(charcode)
else:
diff --git a/Tools/scripts/pathfix.py b/Tools/scripts/pathfix.py
index 22432d1..562bbc7 100755
--- a/Tools/scripts/pathfix.py
+++ b/Tools/scripts/pathfix.py
@@ -64,7 +64,7 @@ def main():
if fix(arg): bad = 1
sys.exit(bad)
-ispythonprog = re.compile('^[a-zA-Z0-9_]+\.py$')
+ispythonprog = re.compile(r'^[a-zA-Z0-9_]+\.py$')
def ispython(name):
return bool(ispythonprog.match(name))
diff --git a/Tools/scripts/ptags.py b/Tools/scripts/ptags.py
index ca643b3..396cbd0 100755
--- a/Tools/scripts/ptags.py
+++ b/Tools/scripts/ptags.py
@@ -24,7 +24,7 @@ def main():
for s in tags: fp.write(s)
-expr = '^[ \t]*(def|class)[ \t]+([a-zA-Z0-9_]+)[ \t]*[:\(]'
+expr = r'^[ \t]*(def|class)[ \t]+([a-zA-Z0-9_]+)[ \t]*[:\(]'
matcher = re.compile(expr)
def treat_file(filename):
diff --git a/Tools/scripts/svneol.py b/Tools/scripts/svneol.py
index 8abdd01..6c70da9 100755
--- a/Tools/scripts/svneol.py
+++ b/Tools/scripts/svneol.py
@@ -1,6 +1,6 @@
#! /usr/bin/env python3
-"""
+r"""
SVN helper script.
Try to set the svn:eol-style property to "native" on every .py, .txt, .c and
diff --git a/Tools/scripts/texi2html.py b/Tools/scripts/texi2html.py
index 9983528..9c1e9fe 100755
--- a/Tools/scripts/texi2html.py
+++ b/Tools/scripts/texi2html.py
@@ -78,11 +78,11 @@ spprog = re.compile('[\n@{}&<>]') # Special characters in
# running text
#
# menu item (Yuck!)
-miprog = re.compile('^\* ([^:]*):(:|[ \t]*([^\t,\n.]+)([^ \t\n]*))[ \t\n]*')
-# 0 1 1 2 3 34 42 0
-# ----- ---------- ---------
-# -|-----------------------------
-# -----------------------------------------------------
+miprog = re.compile(r'^\* ([^:]*):(:|[ \t]*([^\t,\n.]+)([^ \t\n]*))[ \t\n]*')
+# 0 1 1 2 3 34 42 0
+# ----- ---------- ---------
+# -|-----------------------------
+# -----------------------------------------------------
diff --git a/Tools/unicode/gencodec.py b/Tools/unicode/gencodec.py
index 4c21469..31f0112 100644
--- a/Tools/unicode/gencodec.py
+++ b/Tools/unicode/gencodec.py
@@ -37,11 +37,11 @@ UNI_UNDEFINED = chr(0xFFFE)
# Placeholder for a missing code point
MISSING_CODE = -1
-mapRE = re.compile('((?:0x[0-9a-fA-F]+\+?)+)'
- '\s+'
- '((?:(?:0x[0-9a-fA-Z]+|<[A-Za-z]+>)\+?)*)'
- '\s*'
- '(#.+)?')
+mapRE = re.compile(r'((?:0x[0-9a-fA-F]+\+?)+)'
+ r'\s+'
+ r'((?:(?:0x[0-9a-fA-Z]+|<[A-Za-z]+>)\+?)*)'
+ r'\s*'
+ r'(#.+)?')
def parsecodes(codes, len=len, range=range):