diff options
author | Daniel Black <grooverdan@users.sourceforge.net> | 2013-12-27 20:01:43 +0000 |
---|---|---|
committer | Daniel Black <grooverdan@users.sourceforge.net> | 2013-12-27 20:01:43 +0000 |
commit | 18fbfed91f426206860227ca32fab4283f998451 (patch) | |
tree | 74a72e09e1813909fce25b9832176acba56efe3f /fail2ban/server/failregex.py | |
parent | 1f1fe254a63a6ba2c28c4071b6b480aa9d5b631c (diff) | |
download | fail2ban-18fbfed91f426206860227ca32fab4283f998451.tar.gz |
ENH: error handling on re.group KeyError exception only for PyPy
Diffstat (limited to 'fail2ban/server/failregex.py')
-rw-r--r-- | fail2ban/server/failregex.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/fail2ban/server/failregex.py b/fail2ban/server/failregex.py index ba176ceb..d3299144 100644 --- a/fail2ban/server/failregex.py +++ b/fail2ban/server/failregex.py @@ -21,7 +21,7 @@ __author__ = "Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" -import re, sre_constants +import re, sre_constants, sys ## # Regular expression class. @@ -136,8 +136,12 @@ class Regex: if self._matchCache.group("skiplines%i" % n) is not None: skippedLines += self._matchCache.group("skiplines%i" % n) n += 1 + except IndexError: + break # KeyError is because of PyPy issue1665 affecting pypy <= 2.2.1 - except (IndexError, KeyError): + except KeyError: + if 'PyPy' not in sys.version: # pragma: no cover - not sure this is even reachable + raise break return skippedLines.splitlines(False) |