diff --git a/register.py b/register.py index f7c0b9be0..b71341a34 100644 --- a/register.py +++ b/register.py @@ -1,10 +1,11 @@ import pypandoc +from io import open 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 = 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 @@ -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 open('./README.txt', 'w', encoding='utf-8') as f: + f.write(final_text) diff --git a/sendgrid/helpers/inbound/send.py b/sendgrid/helpers/inbound/send.py index 9cbb5aa6c..fe67aca46 100644 --- a/sendgrid/helpers/inbound/send.py +++ b/sendgrid/helpers/inbound/send.py @@ -2,6 +2,7 @@ Usage: ./send.py [path to file containing test data]""" import argparse import sys +from io import open try: from config import Config except ImportError: @@ -26,9 +27,9 @@ def test_payload(self, payload_filepath): "Content-Type": "multipart/form-data; boundary=xYzZY" } client = Client(host=self.url, request_headers=headers) - with open(payload_filepath, 'r') as f: - data = f.read() - return client.post(request_body=data) + f = open(payload_filepath, 'r', encoding='utf-8') + data = f.read() + return client.post(request_body=data) @property def url(self): diff --git a/sendgrid/helpers/mail/asm.py b/sendgrid/helpers/mail/asm.py index 8187aaba7..333f3e98c 100644 --- a/sendgrid/helpers/mail/asm.py +++ b/sendgrid/helpers/mail/asm.py @@ -9,8 +9,14 @@ def __init__(self, group_id=None, groups_to_display=None): :param groups_to_display: Unsubscribe groups to display :type groups_to_display: list(int), optional """ - self.group_id = group_id - self.groups_to_display = groups_to_display + self._group_id = None + self._groups_to_display = None + + if group_id is not None: + self.group_id = group_id + + if groups_to_display is not None: + self.groups_to_display = groups_to_display @property def group_id(self): diff --git a/setup.py b/setup.py index f95e4ee40..014691b61 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ import sys import os +from io import open from setuptools import setup, find_packages __version__ = None @@ -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 = open('README.txt', 'r', encoding='utf-8').read() def getRequires():