summaryrefslogtreecommitdiff
path: root/fail2ban/helpers.py
diff options
context:
space:
mode:
authorsebres <serg.brester@sebres.de>2023-04-04 12:46:35 +0200
committersebres <serg.brester@sebres.de>2023-04-04 12:48:12 +0200
commit56485c8548785de5083f53beb33b42228d756fc9 (patch)
tree064eb293a9595bb4ac20d649a9f47752c2690f14 /fail2ban/helpers.py
parenta9b30eb86ea4367e7464c90f517b1e1da9c88020 (diff)
downloadfail2ban-56485c8548785de5083f53beb33b42228d756fc9.tar.gz
filtertestcase.py: byte related copy of lines in tests (locale independent); closes gh-2936
Diffstat (limited to 'fail2ban/helpers.py')
-rw-r--r--fail2ban/helpers.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/fail2ban/helpers.py b/fail2ban/helpers.py
index 5c1750a6..de8a2794 100644
--- a/fail2ban/helpers.py
+++ b/fail2ban/helpers.py
@@ -98,6 +98,8 @@ if sys.version_info >= (3,): # pragma: 2.x no cover
if not isinstance(x, bytes):
return str(x)
return x.decode(PREFER_ENC, 'replace')
+ def uni_bytes(x):
+ return bytes(x, 'UTF-8')
else: # pragma: 3.x no cover
def uni_decode(x, enc=PREFER_ENC, errors='strict'):
try:
@@ -115,6 +117,7 @@ else: # pragma: 3.x no cover
return x.encode(PREFER_ENC, 'replace')
else:
uni_string = str
+ uni_bytes = bytes
def _as_bool(val):