From e8ab39dee2c6a582ddfce92999026bff8025272a Mon Sep 17 00:00:00 2001 From: Stefan Hasselgren Date: Thu, 17 Oct 2019 17:47:10 +0200 Subject: [PATCH 1/2] Fix ResourceWarning on module import --- python_http_client/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python_http_client/__init__.py b/python_http_client/__init__.py index 0d88104..79b74b2 100644 --- a/python_http_client/__init__.py +++ b/python_http_client/__init__.py @@ -19,4 +19,5 @@ dir_path = os.path.dirname(os.path.realpath(__file__)) if os.path.isfile(os.path.join(dir_path, 'VERSION.txt')): - __version__ = open(os.path.join(dir_path, 'VERSION.txt')).read().strip() + with open(os.path.join(dir_path, 'VERSION.txt')) as version_file: + __version__ = version_file.read().strip() From 25b02a06bdde36204445832942db54a895106d3c Mon Sep 17 00:00:00 2001 From: Stefan Hasselgren Date: Thu, 17 Oct 2019 18:07:51 +0200 Subject: [PATCH 2/2] Fix ResourceWarning in setup.py --- setup.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index cab04ab..afa54a6 100755 --- a/setup.py +++ b/setup.py @@ -5,9 +5,10 @@ dir_path = os.path.abspath(os.path.dirname(__file__)) -readme = io.open(os.path.join(dir_path, 'README.rst'), encoding='utf-8').read() -version = io.open(os.path.join(dir_path, 'VERSION.txt'), - encoding='utf-8').read().strip() +with io.open(os.path.join(dir_path, 'README.rst'), encoding='utf-8') as readme_file: + readme = readme_file.read() +with io.open(os.path.join(dir_path, 'VERSION.txt'), encoding='utf-8') as version_file: + version = version_file.read().strip() base_url = 'https://github.com/sendgrid/' copy_file(os.path.join(dir_path, 'VERSION.txt'),