summaryrefslogtreecommitdiff
path: root/configobj.py
diff options
context:
space:
mode:
Diffstat (limited to 'configobj.py')
-rw-r--r--configobj.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/configobj.py b/configobj.py
index 2d6f267..ef064e4 100644
--- a/configobj.py
+++ b/configobj.py
@@ -2117,10 +2117,10 @@ class ConfigObj(Section):
if outfile is not None:
outfile.write(output)
else:
- h = open(self.filename, 'wb')
- h.write(output)
- h.close()
-
+ with open(self.filename, 'wb') as h:
+ h.write(output.encode(self.encoding or
+ self.default_encoding or
+ 'ascii'))
def validate(self, validator, preserve_errors=False, copy=False,
section=None):