summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAarni Koskela <akx@iki.fi>2018-01-15 14:18:03 +0200
committerGitHub <noreply@github.com>2018-01-15 14:18:03 +0200
commitf60cad28dd02ace28f495c61547e4f19a320289f (patch)
tree1f2e787785f6d33276dfb255614ba6ff614e3a24
parentedfb518a589aa6d7bc4243dc2430a5b0f200ca8c (diff)
parentf2626a8793575c291ed8d9edbb0b99778a964dfa (diff)
downloadbabel-f60cad28dd02ace28f495c61547e4f19a320289f.tar.gz
Merge pull request #528 from scop/escseq
Invalid string escape sequence related fixes
-rw-r--r--babel/core.py2
-rw-r--r--babel/dates.py4
-rw-r--r--babel/localtime/_unix.py15
-rw-r--r--babel/messages/checkers.py2
-rw-r--r--babel/messages/frontend.py2
-rwxr-xr-xscripts/make-release.py2
6 files changed, 9 insertions, 18 deletions
diff --git a/babel/core.py b/babel/core.py
index 5140f49..c8b1802 100644
--- a/babel/core.py
+++ b/babel/core.py
@@ -1118,7 +1118,7 @@ def parse_locale(identifier, sep='_'):
def get_locale_identifier(tup, sep='_'):
"""The reverse of :func:`parse_locale`. It creates a locale identifier out
of a ``(language, territory, script, variant)`` tuple. Items can be set to
- ``None`` and trailing ``None``\s can also be left out of the tuple.
+ ``None`` and trailing ``None``\\s can also be left out of the tuple.
>>> get_locale_identifier(('de', 'DE', None, '1999'))
'de_DE_1999'
diff --git a/babel/dates.py b/babel/dates.py
index d1fafe2..3a075eb 100644
--- a/babel/dates.py
+++ b/babel/dates.py
@@ -1155,7 +1155,7 @@ def parse_date(string, locale=LC_TIME):
# FIXME: this currently only supports numbers, but should also support month
# names, both in the requested locale, and english
- numbers = re.findall('(\d+)', string)
+ numbers = re.findall(r'(\d+)', string)
year = numbers[indexes['Y']]
if len(year) == 2:
year = 2000 + int(year)
@@ -1198,7 +1198,7 @@ def parse_time(string, locale=LC_TIME):
# and seconds should be optional, maybe minutes too
# oh, and time-zones, of course
- numbers = re.findall('(\d+)', string)
+ numbers = re.findall(r'(\d+)', string)
hour = int(numbers[indexes['H']])
minute = int(numbers[indexes['M']])
second = int(numbers[indexes['S']])
diff --git a/babel/localtime/_unix.py b/babel/localtime/_unix.py
index 8a8b4e9..8f25fe7 100644
--- a/babel/localtime/_unix.py
+++ b/babel/localtime/_unix.py
@@ -100,9 +100,7 @@ def _get_localzone(_root='/'):
# OpenSUSE has a TIMEZONE setting in /etc/sysconfig/clock and
# Gentoo has a TIMEZONE setting in /etc/conf.d/clock
# We look through these files for a timezone:
- zone_re = re.compile('\s*ZONE\s*=\s*\"')
- timezone_re = re.compile('\s*TIMEZONE\s*=\s*\"')
- end_re = re.compile('\"')
+ timezone_re = re.compile(r'\s*(TIME)?ZONE\s*=\s*"(?P<etctz>.+)"')
for filename in ('etc/sysconfig/clock', 'etc/conf.d/clock'):
tzpath = os.path.join(_root, filename)
@@ -110,17 +108,10 @@ def _get_localzone(_root='/'):
continue
with open(tzpath, 'rt') as tzfile:
for line in tzfile:
- # Look for the ZONE= setting.
- match = zone_re.match(line)
- if match is None:
- # No ZONE= setting. Look for the TIMEZONE= setting.
- match = timezone_re.match(line)
+ match = timezone_re.match(line)
if match is not None:
- # Some setting existed
- line = line[match.end():]
- etctz = line[:end_re.search(line).start()]
-
# We found a timezone
+ etctz = match.group("etctz")
return pytz.timezone(etctz.replace(' ', '_'))
# No explicit setting existed. Use localtime
diff --git a/babel/messages/checkers.py b/babel/messages/checkers.py
index 24ecdcf..c4669c5 100644
--- a/babel/messages/checkers.py
+++ b/babel/messages/checkers.py
@@ -61,7 +61,7 @@ def python_format(catalog, message):
def _validate_format(format, alternative):
"""Test format string `alternative` against `format`. `format` can be the
- msgid of a message and `alternative` one of the `msgstr`\s. The two
+ msgid of a message and `alternative` one of the `msgstr`\\s. The two
arguments are not interchangeable as `alternative` may contain less
placeholders if `format` uses named placeholders.
diff --git a/babel/messages/frontend.py b/babel/messages/frontend.py
index fb171e3..388c14b 100644
--- a/babel/messages/frontend.py
+++ b/babel/messages/frontend.py
@@ -391,7 +391,7 @@ class extract_messages(Command):
if self.input_paths:
if isinstance(self.input_paths, string_types):
- self.input_paths = re.split(',\s*', self.input_paths)
+ self.input_paths = re.split(r',\s*', self.input_paths)
elif self.distribution is not None:
self.input_paths = dict.fromkeys([
k.split('.', 1)[0]
diff --git a/scripts/make-release.py b/scripts/make-release.py
index dc9bb31..245608a 100755
--- a/scripts/make-release.py
+++ b/scripts/make-release.py
@@ -23,7 +23,7 @@ def parse_changelog():
with open('CHANGES') as f:
lineiter = iter(f)
for line in lineiter:
- match = re.search('^Version\s+(.*)', line.strip())
+ match = re.search(r'^Version\s+(.*)', line.strip())
if match is None:
continue
version = match.group(1).strip()