Browse Source

Merge pull request #2 from mrksbrg/master

Fixed unicode error on Win10
Oscar Svensson 6 years ago
parent
commit
d59d2defa5
1 changed files with 3 additions and 2 deletions
  1. 3 2
      code/fetch_jira_bugs/fetch.py

+ 3 - 2
code/fetch_jira_bugs/fetch.py

@@ -9,6 +9,7 @@ import urllib.request as url
 import json
 import os
 import argparse
+import io
 
 def fetch():
     """ Fetch issues that match given jql query """
@@ -42,8 +43,8 @@ def fetch():
     print('Progress: | = ' + str(max_results) + ' issues')
     while start_at < total:
         with url.urlopen(request.format(jql, start_at, max_results)) as conn:
-            with open('issues/res' + str(start_at) + '.json', 'w') as f:
-                f.write(conn.read().decode('utf-8'))
+            with io.open('issues/res' + str(start_at) + '.json', 'w', encoding="utf-8") as f:
+                f.write(conn.read().decode('utf-8', 'ignore'))
         print('|', end='', flush='True')
         start_at += max_results