From d6973fbb766db6685d9657f9f8a2408543e0903a Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Mon, 20 Feb 2017 13:18:14 +0100 Subject: [PATCH] Bugfixing because of character encoding --- lib/webhooks/__init__.py | 2 +- lib/webhooks/base_app.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/webhooks/__init__.py b/lib/webhooks/__init__.py index 24b9f3e..77c24cf 100644 --- a/lib/webhooks/__init__.py +++ b/lib/webhooks/__init__.py @@ -1,6 +1,6 @@ #!/bin/env python3 # -*- coding: utf-8 -*- -__version__ = '0.5.4' +__version__ = '0.5.5' # vim: ts=4 et list diff --git a/lib/webhooks/base_app.py b/lib/webhooks/base_app.py index 3d5ab95..f19e087 100644 --- a/lib/webhooks/base_app.py +++ b/lib/webhooks/base_app.py @@ -17,6 +17,8 @@ import json import smtplib import argparse import traceback +import io + from email.message import EmailMessage # Third party modules @@ -514,8 +516,15 @@ class BaseHookApp(object): if self.verbose > 1: LOG.debug("Base directory: {!r}".format(self.base_dir)) + LOG.debug("STDIN object: {}".format(sys.stdin.__class__.__name__)) + LOG.debug("Encoding of STDIN: {!r}".format(sys.stdin.encoding)) + + LOG.debug("Setting encoding of STDIN to 'UTF-8'.") + input_stream = io.TextIOWrapper(sys.stdin.buffer, encoding='UTF-8') + if self.verbose > 2: + LOG.debug("Encoding of STDIN now: {!r}".format(input_stream.encoding)) - self.data = sys.stdin.read() + self.data = input_stream.read() try: self.json_data = json.loads(self.data) if self.verbose > 1: -- 2.39.5