From b3ea5cf5e2a43287471e5dd69a2febb1868fdf07 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Tue, 29 Apr 2014 17:41:41 -0700 Subject: [PATCH] Read using a file handle instead of read() method The read() method silently ignores errors which is not so useful if .gerttyrc doesn't exist, so instead of using that use the readfp which will open the file and then correctly read from the file (and raise if the file does not exist). Change-Id: I3bf68408595e06c6ffb60632b46995c1fadbea3f --- gertty/config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gertty/config.py b/gertty/config.py index 02c412b..4f84434 100644 --- a/gertty/config.py +++ b/gertty/config.py @@ -22,7 +22,8 @@ class Config(object): def __init__(self, server=None, path=DEFAULT_CONFIG_PATH): self.path = os.path.expanduser(path) self.config = ConfigParser.RawConfigParser() - self.config.read(self.path) + with open(self.path, 'r') as f: + self.config.readfp(f, filename=f.name) if server is None: server = self.config.sections()[0] self.server = server