kurtmckee/feedparser

Raise (some) exceptions by default

0x4c47 opened this issue · 1 comments

0x4c47 commented

Exceptions raised within feedparser are currently caught internally and an empty/half-parsed result is returned with the exception in the bozo_exception attribute.

To be honest: I personally think this is not a good design choice for default behavior in Python. I think by default exceptions should be raised for me to be handled. It's confusing because most other librarie do it differently and raise exceptions instead of just returning an empty/incomplete result with special exception attributes.

I understand that the "half-parsing" part could be required in some cases. But that could be something enabled by a parameter instead of doing it by default? Or just include the half-parsed feed in the exception?

E.g. I think for a network timeout error (feedparser doesn't even get any data to parse because the URL is unreachable) it makes no sense at all to return an empty result with a wrapped exception by default. Instead the timeout error should be raised as an exception.

The documentation is also not very clear about this: It suggests that bozo is only about malformed feeds. But in fact it's about all exceptions.

If this topic was already discussed, feel free to close this issue immediately. But I couldn't find anything about this here.

I 100% agree. I'll consider places where raising exceptions makes sense.