From e371273457db0766c721523df40d51f3b07b012d Mon Sep 17 00:00:00 2001 From: Peter Hamilton Date: Thu, 25 Jun 2015 14:27:31 -0400 Subject: [PATCH] Fixing bug with dangling file handle when setting __version__ This change fixes a bug whereby a file handle was left unclosed after being used to dynamically set __version__. --- kmip/__init__.py | 6 ++++-- setup.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/kmip/__init__.py b/kmip/__init__.py index 13022f4..7d978e1 100644 --- a/kmip/__init__.py +++ b/kmip/__init__.py @@ -17,9 +17,11 @@ import logging.config import os import sys -version = os.path.join(os.path.dirname( +# Dynamically set __version__ +version_path = os.path.join(os.path.dirname( os.path.realpath(__file__)), 'version.py') -exec(open(version).read()) +with open(version_path, 'r') as version_file: + exec(version_file.read()) path = os.path.join(os.path.dirname(__file__), 'logconfig.ini') diff --git a/setup.py b/setup.py index 0f7a140..a18acf2 100644 --- a/setup.py +++ b/setup.py @@ -16,9 +16,11 @@ import os import setuptools -version = os.path.join(os.path.dirname( +# Dynamically set __version__ +version_path = os.path.join(os.path.dirname( os.path.realpath(__file__)), 'kmip', 'version.py') -exec(open(version).read()) +with open(version_path, 'r') as version_file: + exec(version_file.read()) setuptools.setup( name='PyKMIP',