Skip to content

Commit

Permalink
python < 2.6 does not have the 'with' statement
Browse files Browse the repository at this point in the history
  • Loading branch information
sivel committed Apr 23, 2014
1 parent 966fd2c commit 8e0d5ea
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@
def find_version(*file_paths):
# Open in Latin-1 so that we avoid encoding errors.
# Use codecs.open for Python 2 compatibility
with codecs.open(os.path.join(here, *file_paths), 'r', 'latin1') as f:
try:
f = codecs.open(os.path.join(here, *file_paths), 'r', 'latin1')
version_file = f.read()
f.close()
except:
raise RuntimeError("Unable to find version string.")

# The version line must have the form
# __version__ = 'ver'
Expand All @@ -44,8 +48,9 @@ def find_version(*file_paths):

# Get the long description from the relevant file
try:
with codecs.open('README.rst', encoding='utf-8') as f:
long_description = f.read()
f = codecs.open('README.rst', encoding='utf-8')
long_description = f.read()
f.close()
except:
long_description = ''

Expand Down

0 comments on commit 8e0d5ea

Please sign in to comment.