Fixed exception handling with YAML and XML parsers.

Without this I would get a traceback when there was an error like `TypeError: coercing to Unicode: need string or buffer, ExpatError found`.