Make str/str8 comparisons return True/False for !=/==.
Code that has been returning str8 becomes much more apparent thanks to this
(e.g., struct module returning str8 for all string-related formats or sqlite3
passing in str8 instances when converting objects that had a __conform__
method). One also has to watch out in C code when making a key from char *
using PyString in the C code but a str instance in Python code as that will not
longer compare equal.
Once str8 gains a constructor like the current bytes type then
test_modulefinder needs a cleanup as the fix is a little messy in that file.
Thanks goes to Thomas Lee for writing the patch for the change giving an
initial run-down of why most of the tests were failing.
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index d33643a..04dddaa 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -200,6 +200,10 @@
self.checkequalnofix('one@two!three!', 'one!two!three!', 'replace', '!', '@', 1)
self.assertRaises(TypeError, 'replace'.replace, "r", 42)
+ def test_str8_comparison(self):
+ self.assertEqual('abc' == str8('abc'), False)
+ self.assertEqual('abc' != str8('abc'), True)
+
def test_comparison(self):
# Comparisons:
self.assertEqual('abc', 'abc')