More meaningful exception message.

While working on back-door publishing of .xml forms to formhub, I was blown away by an AssertionError.  These are normally caused by program logic errors. (Which may have been the case when this module is used for its intended purpose.)  I replaced the two "assert" calls with the more usual Python "easier to get forgiveness than permission" pattern, and a TypeError with some diagnostic text.

It might have been better to raise ValueError, but I noticed that TypeError was used elsewhere in the module.