[meld] filters: Reuse re.compile checking in bytestring regexes
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] filters: Reuse re.compile checking in bytestring regexes
- Date: Sat, 27 Oct 2018 22:06:59 +0000 (UTC)
commit 2a3bb1b5bcc8cc75e16012f6f8e9012ab3921aad
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun Oct 28 07:10:51 2018 +1000
filters: Reuse re.compile checking in bytestring regexes
meld/filters.py | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
---
diff --git a/meld/filters.py b/meld/filters.py
index 8ec8ec32..c2701511 100644
--- a/meld/filters.py
+++ b/meld/filters.py
@@ -34,7 +34,7 @@ class FilterEntry:
@classmethod
def _compile_regex(cls, regex):
try:
- compiled = re.compile("(?m)" + regex)
+ compiled = re.compile(regex, re.M)
except re.error:
compiled = None
return compiled
@@ -46,11 +46,7 @@ class FilterEntry:
# encoding errors with '.'?
regex = regex.encode('utf8', 'replace')
- try:
- compiled = re.compile(b"(?m)" + regex)
- except re.error:
- compiled = None
- return compiled
+ return cls._compile_regex(regex)
@classmethod
def _compile_shell_pattern(cls, pattern):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]