typo in exception handling for get, NoSectionError will be caught as well; initialise ConfigParser in __init__, not in class
This commit is contained in:
		@@ -4,13 +4,14 @@ import sys
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Conf(object):
 | 
			
		||||
    _confobj = configparser.ConfigParser(dict(HOME=os.environ.get('HOME')))
 | 
			
		||||
    _confobj = None
 | 
			
		||||
    _cfgfiles = []
 | 
			
		||||
    debug = None
 | 
			
		||||
 | 
			
		||||
    def __init__(self, filename=None, debug=None, force_filename=False):
 | 
			
		||||
        if debug:
 | 
			
		||||
            self.set_debug(debug)
 | 
			
		||||
        self._confobj = configparser.ConfigParser(dict(HOME=os.environ.get('HOME')))
 | 
			
		||||
        filenames = []
 | 
			
		||||
        if not force_filename:
 | 
			
		||||
            # default config files are $HOME/etc/userconfig2.conf and
 | 
			
		||||
@@ -44,7 +45,7 @@ class Conf(object):
 | 
			
		||||
                return self._confobj.getboolean(section, option)
 | 
			
		||||
            else:
 | 
			
		||||
                return self._confobj.get(section, option)
 | 
			
		||||
        except (configparser.NoOptionError, configparser.NoOptionError) as e:
 | 
			
		||||
        except (configparser.NoOptionError, configparser.NoSectionError) as e:
 | 
			
		||||
            raise ValueError(f'Option {option} does not exist in section {section}: {e}')
 | 
			
		||||
 | 
			
		||||
    def set(self, option, value, section='userconfig'):
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user