From 2c033f549ac6c2b9eff97e983d96b28555c13788 Mon Sep 17 00:00:00 2001 From: Mehdi Zarei Date: Sun, 7 Mar 2021 21:54:23 +0330 Subject: [PATCH] encode utf-8 before log --- instagram_private_api/client.py | 2 +- instagram_web_api/client.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/instagram_private_api/client.py b/instagram_private_api/client.py index a01c5bfc..a1ee4f6c 100644 --- a/instagram_private_api/client.py +++ b/instagram_private_api/client.py @@ -537,7 +537,7 @@ def _call_api(self, endpoint, params=None, query=None, return_response=False, un return response response_content = self._read_response(response) - self.logger.debug('RESPONSE: {0:d} {1!s}'.format(response.code, response_content)) + self.logger.debug('RESPONSE: {0:d} {1!s}'.format(response.code, response_content.encode('utf-8'))) json_response = json.loads(response_content) if json_response.get('message', '') == 'login_required': diff --git a/instagram_web_api/client.py b/instagram_web_api/client.py index 0a2eaf27..ec45ba61 100644 --- a/instagram_web_api/client.py +++ b/instagram_web_api/client.py @@ -280,7 +280,7 @@ def _make_request(self, url, params=None, headers=None, query=None, return res response_content = self._read_response(res) - self.logger.debug('RES BODY: {0!s}'.format(response_content)) + self.logger.debug('RES BODY: {0!s}'.format(response_content.encode('utf-8'))) return json.loads(response_content) except compat_urllib_error.HTTPError as e: @@ -353,7 +353,7 @@ def init(self): init_res = self._make_request( 'https://www.instagram.com/', return_response=True, get_method=lambda: 'GET') init_res_content = self._read_response(init_res) - self.logger.debug('RES BODY: {0!s}'.format(init_res_content)) + self.logger.debug('RES BODY: {0!s}'.format(init_res_content.encode('utf-8'))) rhx_gis = self._extract_rhx_gis(init_res_content) self.rhx_gis = rhx_gis @@ -911,7 +911,7 @@ def post_photo(self, photo_data, caption=''): res = self.opener.open(req, timeout=self.timeout) response_content = self._read_response(res) - self.logger.debug('RESPONSE: {0!s}'.format(response_content)) + self.logger.debug('RESPONSE: {0!s}'.format(response_content.encode('utf-8'))) upload_res = json.loads(response_content) if upload_res.get('status', '') != 'ok': raise ClientError('Upload status: {}'.format(upload_res.get('status', '')))