Raise TypeError if the config file is malformed

Fixes #1504.
A small remark - maybe the message should say something like `Malformed configuration file ...`? //cc @jonas054