[geany/infrastructure] 4bda2b: Encode/decode urllib requests and responses

Enrico Tröger git-noreply at xxxxx
Tue Aug 13 21:47:15 UTC 2019


Branch:      refs/heads/master
Author:      Enrico Tröger <enrico.troeger at uvena.de>
Committer:   Enrico Tröger <enrico.troeger at uvena.de>
Date:        Tue, 13 Aug 2019 21:47:15 UTC
Commit:      4bda2b25b29055bed189bbb2a9b4de0a5563e7cf
             https://github.com/geany/infrastructure/commit/4bda2b25b29055bed189bbb2a9b4de0a5563e7cf

Log Message:
-----------
Encode/decode urllib requests and responses


Modified Paths:
--------------
    scripts/git2irc/git2irc.py

Modified: scripts/git2irc/git2irc.py
4 lines changed, 3 insertions(+), 1 deletions(-)
===================================================================
@@ -136,12 +136,14 @@ def shorten_url(long_url):
             "fullUrl": long_url
         }
     })
+    request_data = request_data.encode('utf-8')
     request_url = config['shortener']['url']
     short_url = long_url  # default is to return same URL (ie. in case of error)
     request = Request(request_url, headers={"User-Agent": USER_AGENT}, data=request_data)
     try:
         resp_file = urlopen(request)
-        resp_dict = loads(resp_file.read())
+        response = resp_file.read()
+        resp_dict = loads(response.decode('utf-8'))
         if int(resp_dict['statusCode']) == 200:
             short_url = resp_dict['url']['shortUrl']
             logger.debug('Shortened URL: {}'.format(short_url))



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list