From f89f48795fdbed07c51aa897eca590a05eb4b746 Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Thu, 29 Dec 2016 00:00:23 -0500 Subject: [PATCH] Pull flags out of regular expressions --- babel/localtime/_unix.py | 2 +- babel/messages/catalog.py | 4 ++-- babel/messages/jslexer.py | 14 +++++++------- babel/plural.py | 2 +- scripts/make-release.py | 8 +++++--- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/babel/localtime/_unix.py b/babel/localtime/_unix.py index 91f03bc9..e0b54fb2 100644 --- a/babel/localtime/_unix.py +++ b/babel/localtime/_unix.py @@ -5,7 +5,7 @@ import sys import pytz import subprocess -_systemconfig_tz = re.compile(r'^Time Zone: (.*)$(?m)') +_systemconfig_tz = re.compile(r'^Time Zone: (.*)$', re.MULTILINE) def _tz_from_env(tzenv): diff --git a/babel/messages/catalog.py b/babel/messages/catalog.py index 9a474a84..018094ca 100644 --- a/babel/messages/catalog.py +++ b/babel/messages/catalog.py @@ -28,7 +28,7 @@ from babel._compat import string_types, number_types, PY2, cmp __all__ = ['Message', 'Catalog', 'TranslationError'] -PYTHON_FORMAT = re.compile(r'''(?x) +PYTHON_FORMAT = re.compile(r''' \% (?:\(([\w]*)\))? ( @@ -37,7 +37,7 @@ PYTHON_FORMAT = re.compile(r'''(?x) [hlL]? ) ([diouxXeEfFgGcrs%]) -''') +''', re.VERBOSE) def _parse_datetime_header(value): diff --git a/babel/messages/jslexer.py b/babel/messages/jslexer.py index a9bab2f2..30d6e540 100644 --- a/babel/messages/jslexer.py +++ b/babel/messages/jslexer.py @@ -25,7 +25,7 @@ escapes = {'b': '\b', 'f': '\f', 'n': '\n', 'r': '\r', 't': '\t'} name_re = re.compile(r'[\w$_][\w\d$_]*', re.UNICODE) dotted_name_re = re.compile(r'[\w$_][\w\d$_.]*[\w\d$_.]', re.UNICODE) division_re = re.compile(r'/=?') -regex_re = re.compile(r'/(?:[^/\\]*(?:\\.[^/\\]*)*)/[a-zA-Z]*(?s)') +regex_re = re.compile(r'/(?:[^/\\]*(?:\\.[^/\\]*)*)/[a-zA-Z]*', re.DOTALL) line_re = re.compile(r'(\r\n|\n|\r)') line_join_re = re.compile(r'\\' + line_re.pattern) uni_escape_re = re.compile(r'[a-fA-F0-9]{1,4}') @@ -33,25 +33,25 @@ uni_escape_re = re.compile(r'[a-fA-F0-9]{1,4}') Token = namedtuple('Token', 'type value lineno') _rules = [ - (None, re.compile(r'\s+(?u)')), + (None, re.compile(r'\s+', re.UNICODE)), (None, re.compile(r'