Skip to content

Commit

Permalink
Provide utf-8 as encoding explicitly when opening text files
Browse files Browse the repository at this point in the history
  • Loading branch information
rshest committed Oct 31, 2017
1 parent 200be7c commit fb3cda1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions register.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import pypandoc
import io

output = pypandoc.convert('README.md', 'rst')
with open('README.txt' 'w+') as f:
f.write(str(output.encode('utf-8')))

readme_rst = open('./README.txt').read()
readme_rst = io.open('./README.txt', 'r', encoding='utf-8').read()
replace = '''
.. figure:: https://uiux.s3.amazonaws.com/2016-logos/email-logo
%402x.png\n :alt: SendGrid Logo\n\n SendGrid Logo\n
Expand All @@ -15,5 +16,5 @@
\n :target: https://www.sendgrid.com
'''
final_text = readme_rst.replace(replace, replacement)
with open('./README.txt', 'w') as f:
f.write(final_text)
with io.open('./README.txt', 'w', encoding='utf-8') as f:
f.write(final_text)
3 changes: 2 additions & 1 deletion sendgrid/helpers/inbound/send.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Usage: ./send.py [path to file containing test data]"""
import argparse
import sys
import io
try:
from config import Config
except ImportError:
Expand All @@ -26,7 +27,7 @@ def test_payload(self, payload_filepath):
"Content-Type": "multipart/form-data; boundary=xYzZY"
}
client = Client(host=self.url, request_headers=headers)
f = open(payload_filepath, 'r')
f = io.open(payload_filepath, 'r', encoding='utf-8')
data = f.read()
return client.post(request_body=data)

Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import os
import io
from setuptools import setup, find_packages

__version__ = None
Expand All @@ -8,7 +9,7 @@

long_description = 'Please see our GitHub README'
if os.path.exists('README.txt'):
long_description = open('README.txt').read()
long_description = io.open('README.txt', 'r', encoding='utf-8').read()


def getRequires():
Expand Down

0 comments on commit fb3cda1

Please sign in to comment.