jonhadfield / python-hosts

a hosts file manager library written in python
MIT License
125 stars 33 forks source link

remove_all_matching(None, name) broken in 0.3.4 if hosts file contains comments. #7

Closed bbeausej closed 7 years ago

bbeausej commented 7 years ago

PR #6 that was merged in 03.4 breaks remove_all_matching for line identified as comments.

Since entry.names is initialized as None by default, comment entries have a None value in the names property. The filtering used in remove_all_matching() in 0.3.4 breaks in those cases.

To replicate simply have a hosts file with comments and invoke remove_all_matching(None, name) to remove an entry by name.

jonhadfield commented 7 years ago

Thanks for reporting @bbeausej. I've just added some tests and pushed a fix in release 0.3.6. Please let me know if this fixes it for you.

bbeausej commented 7 years ago

Hi Jon, Giving it a spin now. Will report in a few.

bbeausej commented 7 years ago

Yessir! This fixes the reported issue.

Thanks for checking it out quickly!

-b