kurtmckee/feedparser

Question: Difference between 'bozo'=1 and 'bozo'=True?

tomofumikitano opened this issue · 1 comments

I just realized freeparser.parse(url) function returns 'bozo'=1 and 'bozo'=True depending on the error type.
I read the "Bozo Detection" section in official documentation and am aware of bozo=1 and bozo=True means some kind of error. I'm using version 6.0.8.

So my question is: Is there good reason feedparser.parse() returns bozo=1 in some case and bozo=True in other? Is there any minor difference that user have to be aware of?

Non existent URL - { bozo: True }

> url = 'https://nonexistenturl.org/'
> { k:v for k,v in feedparser.parse(url).items() if k in {'bozo', 'bozo_exception'} }
{'bozo': True,
 'bozo_exception': urllib.error.URLError(socket.gaierror(8,
                                       'nodename nor servname provided, or not known'))}

Well formed feed - { bozo: False }

> url = 'https://jvns.ca/atom.xml'
> { k:v for k,v in feedparser.parse(url).items() if k in {'bozo', 'bozo_exception'} }
{'bozo': False}

This sample code returns {'bozo': 0} by the way.
https://feedparser.readthedocs.io/en/latest/bozo.html#detecting-a-non-well-formed-feed

Non-well-formed feed - { bozo: 1 }

> url = 'https://jvns.ca'
> { k:v for k,v in feedparser.parse(url).items() if k in {'bozo', 'bozo_exception'}}
{'bozo': 1,
 'bozo_exception': xml.sax._exceptions.SAXParseException('not well-formed (invalid token)')}

No differences are intended here, it just means that I missed some areas of the code and docs when I was migrating from 1 to True.

Thanks for pointing this out, I'll work to get it fixed!