[Python-3000] bsddb finished for 2.6/3.0 (and "<class 'BytesWarning'>: str() on a bytes instance")
Christian Heimes
lists at cheimes.de
Wed Sep 3 20:36:48 CEST 2008
Jesus Cea wrote:
> I can't reproduce the issue in my local Python3.0 development version
> (here, all tests passes fine). Any suggestion?.
Yeah, use my byte warning mode of Python 3.0. Before your time in the
core team I had a long discussion with Guido and a few others. The
conclusion of the discussion was the byte warning mode.
./python --help
-b : issue warnings about str(bytes_instance), str(buffer_instance)
and comparing bytes/buffer with str. (-bb: issue errors)
By the way buffer_instance should be renamed to bytearray.
./python -bb
Python 3.0b3+ (py3k:66180M, Sep 3 2008, 12:35:13)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> str(b'')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
BytesWarning: str() on a bytes instance
[41030 refs]
> "Decoding" the "db.DB_VERSION_STRING" byte string would solve the error,
> but I rather prefer to know WHY I am having this issue at all. My
> Python3.0 "str()" has no any issue with byte values:
It has no issues because Guido wanted str() to successed. Any comparison
or conversion of a byte / bytearray instance with / to str is most
likely a bug or design flaw in the application. The byte warning mode
helps to discover hard to find bugs like "" == b"".
Christian
More information about the Python-3000
mailing list