Closed jeverling closed 5 years ago
oh, returning none is bad behavior. at least, should be error is raised
Honestly, I don't like treating bytes type as string. But, so, semver format is not including multi bytes char, normaly.
I think it's enough to raise the error, it is then up to the user to make sure to pass strings not bytes. But at the moment it's not easy to see why it doesn't work.
0.6.0 is released
from semver import max_satisfying
print(max_satisfying([b"1.0.0"], "1.0.0"))
# semver.InvalidTypeIncluded: must be str, but b'1.0.0'
print(max_satisfying(["1.0.0"], b"1.0.0"))
# semver.InvalidTypeIncluded: must be str, but b'1.0.0'
Thank you for the quick fix!
Using Python 3, if you pass byte-strings to
max_satisfying
, it returnsNone
.The reason is a
TypeError: cannot use a string pattern on a bytes-like object
exception in semver#L740, however this exception is masked by a bareexcept
statement in semver#L1079, that leads tomax_satisfying
returningNone
.I think it would be good to document that byte-strings need to be decoded before they can be passed to semver. Alternatively, the library could try to decode byte-strings before using them, which should be reasonably easy because semvers are supposed to be ascii only.