Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
On Python 3, the default string is of Unicode type, which caused this comparison some issues. In particular, the length comparison was off as the Unicode string may have more bytes than the equivalent ASCII string. To fix that, just encode Unicode strings as ASCII and convert them to C strings. This handles Python byte strings just as well. Then it is a simple matter to compare the string length and string value. If the encoding goes wrong (like if it isn't any kind of string), then we get a `NULL` value, which we raise for just like if the string didn't match the right value.
- Loading branch information