A quick temporary hack is to use buffer(b'abc') instead. (buffer() is so incredibly broken that it lets you hash() even if the underlying object is broken. :-)
The correct solution is to fix the re library to avoid using hash() directly on the underlying data type altogether; that never had sound semantics (as proven by the buffer() hack above). --Guido On 8/8/07, Victor Stinner <[EMAIL PROTECTED]> wrote: > Hi, > > Since Python 3000 regular expressions are now Unicode by default, how can I > use bytes regex? Very simplified example of my problem: > import re > print( re.sub("(.)", b"[\\1]", b'abc') ) > > This code fails with exception: > File "(...)/py3k-struni/Lib/re.py", line 241, in _compile_repl > p = _cache_repl.get(key) > TypeError: unhashable type: 'bytes' > > Does "frozen bytes type" (immutable) exist to be able to use a cache? > > Victor Stinner aka haypo > http://hachoir.org/ > _______________________________________________ > Python-3000 mailing list > Python-3000@python.org > http://mail.python.org/mailman/listinfo/python-3000 > Unsubscribe: > http://mail.python.org/mailman/options/python-3000/guido%40python.org > -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com