summaryrefslogtreecommitdiff
path: root/fail2ban/helpers.py
diff options
context:
space:
mode:
authorsebres <serg.brester@sebres.de>2018-07-11 13:21:53 +0200
committersebres <serg.brester@sebres.de>2018-07-11 13:21:53 +0200
commit94ffd00328af29304110df55ceffe2863b4afaf8 (patch)
tree660446466d0de92de48b7953978faa3fcda46d58 /fail2ban/helpers.py
parentcc321b78da8e27d4d8b2ed885667ecb9e7ba2849 (diff)
downloadfail2ban-94ffd00328af29304110df55ceffe2863b4afaf8.tar.gz
fixes initialization bug if sys.stdout.encoding is None (closes gh-2177).
Diffstat (limited to 'fail2ban/helpers.py')
-rw-r--r--fail2ban/helpers.py3
1 files changed, 1 insertions, 2 deletions
diff --git a/fail2ban/helpers.py b/fail2ban/helpers.py
index 5681c31b..49a5ca47 100644
--- a/fail2ban/helpers.py
+++ b/fail2ban/helpers.py
@@ -32,11 +32,10 @@ from threading import Lock
from .server.mytime import MyTime
-
PREFER_ENC = locale.getpreferredencoding()
# correct preferred encoding if lang not set in environment:
if PREFER_ENC.startswith('ANSI_'): # pragma: no cover
- if sys.stdout and not sys.stdout.encoding.startswith('ANSI_'):
+ if sys.stdout and sys.stdout.encoding is not None and not sys.stdout.encoding.startswith('ANSI_'):
PREFER_ENC = sys.stdout.encoding
elif all((os.getenv(v) in (None, "") for v in ('LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'LANG'))):
PREFER_ENC = 'UTF-8';