Skip to content

Commit

Permalink
Py3 compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
idlesign committed Jul 26, 2017
1 parent 2d7d8ba commit 6b4f646
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions uwsgiconf/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,14 +495,13 @@ def tofile(self, filepath=None):
"""
if filepath is None:
target_file = NamedTemporaryFile(prefix='uwsgicfg_', suffix='.ini', delete=False)
filepath = target_file.name
with NamedTemporaryFile(prefix='uwsgicfg_', suffix='.ini', delete=False) as f:
filepath = f.name

else:
filepath = os.path.abspath(filepath)
target_file = open(filepath, 'w')

with target_file as target_file:
with open(filepath, 'w') as target_file:
target_file.write(self.format())
target_file.flush()

Expand Down

0 comments on commit 6b4f646

Please sign in to comment.