# Buggy code
def configure_setting(self, name, prompt=None, default=NO_DEFAULT):
    """Return a validated value for this attribute from the terminal.

    ``prompt`` will be the docstring of the attribute if not given.

    If ``default`` is passed, it will be used if no value is given by the
    user. If it is not passed, the current value of the setting, or the
    default value if it's unset, will be used. Note that if ``default`` is
    passed, the current value of the setting will be ignored, even if it is
    not the attribute's default.
    """
    clazz = getattr(self.__class__, name)
    prompt = prompt or clazz.__doc__
    if default is NO_DEFAULT:
        try:
            default = getattr(self, name)
        except AttributeError:
            pass
        except ValueError:
            print("The configured value for this option was invalid.")
            if clazz.default is not NO_DEFAULT:
                default = clazz.default
    while True:
        try:
            value = clazz.configure(prompt, default)
        except ValueError as exc:
            print(exc)
        else:
            break
    setattr(self, name, value)


# Traceback (TypeError)
Configure safety module (y/n)? [n]y
Encountered an error while writing the config file. This shouldn't happen. Check permissions.
Traceback (most recent call last):
File "/usr/local/bin/sopel", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python3.4/dist-packages/sopel/run_script.py", line 133, in main
_create_config(configpath)
File "/usr/local/lib/python3.4/dist-packages/sopel/config/__init__.py", line 254, in _create_config
config._modules()
File "/usr/local/lib/python3.4/dist-packages/sopel/config/__init__.py", line 207, in _modules
module.configure(self)
File "/usr/local/lib/python3.4/dist-packages/sopel/modules/safety.py", line 49, in configure
config.safety.configure_setting('enabled_by_default')
File "/usr/local/lib/python3.4/dist-packages/sopel/config/types.py", line 96, in configure_setting
value = clazz.configure(prompt, default)
File "/usr/local/lib/python3.4/dist-packages/sopel/config/types.py", line 205, in configure
prompt += ' (y/n)'
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'str'

# Fixed code
def configure_setting(self, name, prompt, default=NO_DEFAULT):
    """Return a validated value for this attribute from the terminal.

    ``prompt`` will be the docstring of the attribute if not given.

    If ``default`` is passed, it will be used if no value is given by the
    user. If it is not passed, the current value of the setting, or the
    default value if it's unset, will be used. Note that if ``default`` is
    passed, the current value of the setting will be ignored, even if it is
    not the attribute's default.
    """
    clazz = getattr(self.__class__, name)
    if default is NO_DEFAULT:
        try:
            default = getattr(self, name)
        except AttributeError:
            pass
        except ValueError:
            print("The configured value for this option was invalid.")
            if clazz.default is not NO_DEFAULT:
                default = clazz.default
    while True:
        try:
            value = clazz.configure(prompt, default)
        except ValueError as exc:
            print(exc)
        else:
            break
    setattr(self, name, value)