This should probably be `if isinstance(tag_val, bool) or tag_val is default`, otherwise it will crash when the tag isn't present and default is not a bool (this arguably shouldn't really happen).

Actually it should probably just be `if tag_val is default`, since the point of testing tag_val is to make sure it's a string because the following lines expect it to be.