Keymap: load/save improvements

- avoid passing redundant operator name to keymap property set function.
- avoid double attr lookups when setting each property.
- handle exceptions on value type mismatch.
- avoid resource warning on failed load.
This commit is contained in:
2014-02-19 10:26:53 +11:00
parent 7afbdbf812
commit 2a9e33fba5
2 changed files with 12 additions and 9 deletions

View File

@@ -494,10 +494,10 @@ def keyconfig_set(filepath, report=None):
keyconfigs_old = keyconfigs[:]
try:
keyfile = open(filepath)
exec(compile(keyfile.read(), filepath, "exec"), {"__file__": filepath})
keyfile.close()
error_msg = ""
with open(filepath, 'r', encoding='utf-8') as keyfile:
exec(compile(keyfile.read(), filepath, "exec"),
{"__file__": filepath})
except:
import traceback
error_msg = traceback.format_exc()