The bugfix releases continue. This one fixes a conceptual problem in the new filtering code which could cause a find-type method (but not a find_all-type method) to incorrectly return None when called without arguments.
My best guess is that this didn't show up earlier because calling a find-type method without arguments is supposed to give the same result as accessing the corresponding navigation element, and most people use the navigation element (as they should; it's more efficient and easier to type).
The single CHANGELOG entry for this release:
* Gave ElementFilter the ability to explicitly say that it excludes
every item in the parse tree. This is used internally in situations
where the provided filters are logically inconsistent or match a
value against the null set.
Without this, it's not always possible to distinguish between
a SoupStrainer that excludes everything and one that excludes
nothing.
This fixes a bug where calls to find_* methods with no arguments
returned None, instead of the first item out of the iterator. [bug=2097333]
Things added to the API to support this:
- The ElementFilter.includes_everything property
- The MatchRule.exclude_everything member
- The _known_rules argument to ElementFilter.match. This is an optional
argument used internally to indicate that an optimization is safe.