Commit 9b46d3fc authored by Antoine Pitrou's avatar Antoine Pitrou

#2834: Change re module semantics, so that str and bytes mixing is forbidden,

and str (unicode) patterns get full unicode matching by default. The re.ASCII
flag is also introduced to ask for ASCII matching instead.
parent dd8e8710
...@@ -409,7 +409,7 @@ def get_versions(): ...@@ -409,7 +409,7 @@ def get_versions():
out = os.popen(gcc_exe + ' -dumpversion','r') out = os.popen(gcc_exe + ' -dumpversion','r')
out_string = out.read() out_string = out.read()
out.close() out.close()
result = re.search('(\d+\.\d+(\.\d+)*)',out_string) result = re.search('(\d+\.\d+(\.\d+)*)', out_string, re.ASCII)
if result: if result:
gcc_version = StrictVersion(result.group(1)) gcc_version = StrictVersion(result.group(1))
else: else:
...@@ -421,7 +421,7 @@ def get_versions(): ...@@ -421,7 +421,7 @@ def get_versions():
out = os.popen(ld_exe + ' -v','r') out = os.popen(ld_exe + ' -v','r')
out_string = out.read() out_string = out.read()
out.close() out.close()
result = re.search('(\d+\.\d+(\.\d+)*)',out_string) result = re.search('(\d+\.\d+(\.\d+)*)', out_string, re.ASCII)
if result: if result:
ld_version = StrictVersion(result.group(1)) ld_version = StrictVersion(result.group(1))
else: else:
...@@ -433,7 +433,7 @@ def get_versions(): ...@@ -433,7 +433,7 @@ def get_versions():
out = os.popen(dllwrap_exe + ' --version','r') out = os.popen(dllwrap_exe + ' --version','r')
out_string = out.read() out_string = out.read()
out.close() out.close()
result = re.search(' (\d+\.\d+(\.\d+)*)',out_string) result = re.search(' (\d+\.\d+(\.\d+)*)', out_string, re.ASCII)
if result: if result:
dllwrap_version = StrictVersion(result.group(1)) dllwrap_version = StrictVersion(result.group(1))
else: else:
......
...@@ -300,7 +300,7 @@ def get_versions(): ...@@ -300,7 +300,7 @@ def get_versions():
out = os.popen(gcc_exe + ' -dumpversion','r') out = os.popen(gcc_exe + ' -dumpversion','r')
out_string = out.read() out_string = out.read()
out.close() out.close()
result = re.search('(\d+\.\d+\.\d+)',out_string) result = re.search('(\d+\.\d+\.\d+)', out_string, re.ASCII)
if result: if result:
gcc_version = StrictVersion(result.group(1)) gcc_version = StrictVersion(result.group(1))
else: else:
......
...@@ -512,7 +512,7 @@ def get_config_vars(*args): ...@@ -512,7 +512,7 @@ def get_config_vars(*args):
# patched up as well. # patched up as well.
'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'): 'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'):
flags = _config_vars[key] flags = _config_vars[key]
flags = re.sub('-arch\s+\w+\s', ' ', flags) flags = re.sub('-arch\s+\w+\s', ' ', flags, re.ASCII)
flags = re.sub('-isysroot [^ \t]*', ' ', flags) flags = re.sub('-isysroot [^ \t]*', ' ', flags)
_config_vars[key] = flags _config_vars[key] = flags
......
...@@ -81,7 +81,7 @@ def get_platform (): ...@@ -81,7 +81,7 @@ def get_platform ():
return "%s-%s.%s" % (osname, version, release) return "%s-%s.%s" % (osname, version, release)
elif osname[:6] == "cygwin": elif osname[:6] == "cygwin":
osname = "cygwin" osname = "cygwin"
rel_re = re.compile (r'[\d.]+') rel_re = re.compile (r'[\d.]+', re.ASCII)
m = rel_re.match(release) m = rel_re.match(release)
if m: if m:
release = m.group() release = m.group()
......
...@@ -134,7 +134,7 @@ class StrictVersion (Version): ...@@ -134,7 +134,7 @@ class StrictVersion (Version):
""" """
version_re = re.compile(r'^(\d+) \. (\d+) (\. (\d+))? ([ab](\d+))?$', version_re = re.compile(r'^(\d+) \. (\d+) (\. (\d+))? ([ab](\d+))?$',
re.VERBOSE) re.VERBOSE | re.ASCII)
def parse (self, vstring): def parse (self, vstring):
......
...@@ -5,7 +5,8 @@ import distutils.version ...@@ -5,7 +5,8 @@ import distutils.version
import operator import operator
re_validPackage = re.compile(r"(?i)^\s*([a-z_]\w*(?:\.[a-z_]\w*)*)(.*)") re_validPackage = re.compile(r"(?i)^\s*([a-z_]\w*(?:\.[a-z_]\w*)*)(.*)",
re.ASCII)
# (package) (rest) # (package) (rest)
re_paren = re.compile(r"^\s*\((.*)\)\s*$") # (list) inside of parentheses re_paren = re.compile(r"^\s*\((.*)\)\s*$") # (list) inside of parentheses
...@@ -153,7 +154,8 @@ def split_provision(value): ...@@ -153,7 +154,8 @@ def split_provision(value):
global _provision_rx global _provision_rx
if _provision_rx is None: if _provision_rx is None:
_provision_rx = re.compile( _provision_rx = re.compile(
"([a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*)(?:\s*\(\s*([^)\s]+)\s*\))?$") "([a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*)(?:\s*\(\s*([^)\s]+)\s*\))?$",
re.ASCII)
value = value.strip() value = value.strip()
m = _provision_rx.match(value) m = _provision_rx.match(value)
if not m: if not m:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment