]> jfr.im git - erebus.git/commitdiff
fix config bug
authorzonidjan <redacted>
Sun, 23 Aug 2020 08:04:55 +0000 (03:04 -0500)
committerzonidjan <redacted>
Sun, 23 Aug 2020 08:04:55 +0000 (03:04 -0500)
config.py

index c1f61b4cb152b4eee008aae37296324cea990904..b05089249cef45bb1b1e5c552c6b8cdd0c0df9f7 100644 (file)
--- a/config.py
+++ b/config.py
@@ -3,7 +3,7 @@
 # "Config" class (reading/providing access to bot.config)
 
 from __future__ import print_function
-import sys
+import sys, os
 
 if sys.version_info.major < 3:
        import ConfigParser
@@ -55,12 +55,13 @@ class Config(object):
        def set(self, section, key, value):
                if not self.config.has_section(section):
                        self.config.add_section(section)
-               self.config.set(section, key, value)
+               self.config.set(section, key, str(value))
                if self.writeout: self.write()
 
        def write(self):
-               with open(self.filename, 'wb') as configfile:
+               with open(self.filename+'.tmp', 'wb') as configfile:
                        self.config.write(configfile)
+                       os.rename(configfile.name, self.filename)
 
        def __del__(self):
                if self.writeout: self.write()