#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.
This commit is contained in:
R David Murray 2016-09-08 13:59:53 -04:00
parent 513d7478a1
commit 44b548dda8
83 changed files with 324 additions and 324 deletions

View file

@ -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)

View file

@ -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('//.*')

View file

@ -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'''

View file

@ -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),

View file

@ -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:

View file

@ -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))

View file

@ -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):

View file

@ -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

View file

@ -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
# ----- ---------- ---------
# -|-----------------------------
# -----------------------------------------------------