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/modulefinder.py | |
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/modulefinder.py')
-rw-r--r-- | Lib/modulefinder.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Lib/modulefinder.py b/Lib/modulefinder.py index 1dbc5bb..cd9906c 100644 --- a/Lib/modulefinder.py +++ b/Lib/modulefinder.py @@ -16,12 +16,13 @@ else: # remain compatible with Python < 2.3 READ_MODE = "r" -LOAD_CONST = chr(dis.opname.index('LOAD_CONST')) -IMPORT_NAME = chr(dis.opname.index('IMPORT_NAME')) -STORE_NAME = chr(dis.opname.index('STORE_NAME')) -STORE_GLOBAL = chr(dis.opname.index('STORE_GLOBAL')) +# XXX Clean up once str8's cstor matches bytes. +LOAD_CONST = str8(chr(dis.opname.index('LOAD_CONST'))) +IMPORT_NAME = str8(chr(dis.opname.index('IMPORT_NAME'))) +STORE_NAME = str8(chr(dis.opname.index('STORE_NAME'))) +STORE_GLOBAL = str8(chr(dis.opname.index('STORE_GLOBAL'))) STORE_OPS = [STORE_NAME, STORE_GLOBAL] -HAVE_ARGUMENT = chr(dis.HAVE_ARGUMENT) +HAVE_ARGUMENT = str8(chr(dis.HAVE_ARGUMENT)) # Modulefinder does a good job at simulating Python's, but it can not # handle __path__ modifications packages make at runtime. Therefore there @@ -367,7 +368,7 @@ class ModuleFinder: consts = co.co_consts LOAD_LOAD_AND_IMPORT = LOAD_CONST + LOAD_CONST + IMPORT_NAME while code: - c = chr(code[0]) + c = str8(chr(code[0])) if c in STORE_OPS: oparg, = unpack('<H', code[1:3]) yield "store", (names[oparg],) |