Setting _filters to None when filter Iterator is empty#325
Setting _filters to None when filter Iterator is empty#325felixdivo merged 4 commits intohardbyte:developfrom pierreluctg:patch-1
Conversation
For example when using `can.logger` the default filter value is a empty list, this leads to filtering all message. This change fix the issue by treating any empty Iterator as filter==None
|
@hardbyte What is your opinion on that one? Currently this PR is not passing the match_nothing test in https://github.com/hardbyte/python-can/blob/develop/test/test_message_filtering.py#L49 intruduced by @felixdivo in #277 I am not sure is this test make sense or not. When looking at the interfaces that supports filtering directly, they treat a empty Iterator as no filtering (opposite of the test) |
|
When I implemented that API, I did not find any precise or central documentation on how to handle |
|
When this is actually changed, please update the documentation accordingly. |
|
Tests and doc have been updated |
can/bus.py
Outdated
| All messages that match at least one filter are returned. | ||
| If `filters` is `None`, all messages are matched. | ||
| If it is a zero size interable, no messages are matched. | ||
| If `filters` is `None` or a a zero size interable, all |
There was a problem hiding this comment.
typo here. I'd say "a zero length sequence"
For example when using
can.loggerthe defaultcan_filtersvalue is a empty list, this leads to filtering all message. This change fix the issue by treating any empty Iterator same asfilters=None