#27308: BytesWarning exception raised when running with python 3 -bb option
-------------------------------------+-------------------------------------
Reporter: Gustavo J. A. M. | Owner: nobody
Carneiro |
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Gustavo J. A. M. Carneiro):
{{{
-b Issue warnings about str(bytes_instance),
str(bytear‐
ray_instance) and comparing bytes/bytearray with str.
(-bb:
issue errors)
}}}
The main point is to catch bugs due to mixing bytes vs str. Also, how
many times have you done in Python 3 this type of bug:
{{{
>>> def create_key(param1):
... return "foo:bar:" + str(param1)
...
>>> create_redis_key("zbr")
'foo:bar:zbr'
}}}
But if param1 comes from e.g. a network socket and you forget to decode
the bytes:
{{{
>>> create_key(b"zbr")
"foo:bar:b'zbr'"
}}}
So I like running my app with -bb (just one -b just gives a warning, but
warnings often pass silently). So it is useful if Django works with -bb.
I am certainly running a production Django app with -bb, for a few weeks,
and this is the first problem that I see caused by it.
--
Ticket URL: <https://code.djangoproject.com/ticket/27308#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/068.a8dad6cad6567353f010fd5216544c37%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.