Please change the string comparison to ==.
==
Generally this patch would be good. However, I would prefer setting tagname to '*' if it is None instead of having an extra condition.
tagname
'*'
None
This way we could even consider always filtering the tags with fnmatch. The code would be easier to read but a tiny bit slower.
fnmatch
Pull-Request has been merged by lsedlar