diff options
author | Brett Cannon <bcannon@gmail.com> | 2007-10-22 20:24:51 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2007-10-22 20:24:51 (GMT) |
commit | 4043001f5d84d4919781e34221449047d0690ac8 (patch) | |
tree | 4b4db9f0b748407480aff4f10b99ce70548bfee0 /Lib/sqlite3 | |
parent | 6464d471950c6ee109f82597ff70d755c127074f (diff) | |
download | cpython-4043001f5d84d4919781e34221449047d0690ac8.zip cpython-4043001f5d84d4919781e34221449047d0690ac8.tar.gz cpython-4043001f5d84d4919781e34221449047d0690ac8.tar.bz2 |
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.
Diffstat (limited to 'Lib/sqlite3')
-rw-r--r-- | Lib/sqlite3/test/types.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/sqlite3/test/types.py b/Lib/sqlite3/test/types.py index 1377835..4ff948d 100644 --- a/Lib/sqlite3/test/types.py +++ b/Lib/sqlite3/test/types.py @@ -76,6 +76,10 @@ class SqliteTypeTests(unittest.TestCase): class DeclTypesTests(unittest.TestCase): class Foo: def __init__(self, _val): + if isinstance(_val, str8): + # sqlite3 always calls __init__ with a str8 created from a + # UTF-8 string when __conform__ was used to store the object. + _val = _val.decode('utf8') self.val = _val def __cmp__(self, other): |