NoSectionError does not raise

Issue #10 invalid
Buck Brady
created an issue

the following does not raise a ConfigParser.NoSectionError

  cfg.has_section('Section Name')
except ConfigParser.NoSectionError as err:

The try statment returns that has_section = False however there is no exception raised.

however the following will raise the NoSectionError

  x = cfg.has_section('Section Name')
  if not x:
    raise ConfigParser.NoSectionError('Section Name', )
except ConfigParser.NoSectionError as err:

if this is just user error or just me using this incorrectly I apologize.

Comments (2)

  1. Alexander Burdeinyi

    There is no place for error. ConfigParser method 'has_section' returns boolean value (True or False).

    def has_section(self, section):
        """Indicate whether the named section is present in the configuration.
        The DEFAULT section is not acknowledged.
        return section in self._sections
  2. Log in to comment