This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author xmorel
Recipients serhiy.storchaka, xmorel
Date 2021-03-20.10:48:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1616237306.46.0.916350152544.issue43526@roundup.psfhosted.org>
In-reply-to
Content
> In normal circumstances you should never deal with BytesWarning. The -b option is only used for testing your program for some possible bugs caused by migration from Python 2. If your program always worked only with Python 3, the -b option has no use for you.

That's technically true for perfect programs, but practically if the program is not tested enough it's possible for it to contain unexpected instances of stringifying bytes which pass by mostly unnoticed, just with garbage bits of output which may or may not get reported.

Noticing such cases in an existing codebase is exactly what prompted me to try and enable BytesWarning (and then try and filter them to just conversion warnings, as the category is quite noisy with somewhat uninteresting warnings), and then spend a while trying to understand why programmatically enabling BytesWarning didn't do anything.

As noted in the last paragraph it's fine if `-b` is required to enable the feature, I'd just like to know if it could be documented clearly as it's somewhat frustrating to pore over the documentation of `warnings`, `BytesWarning`, and `-b`, diff the state of the filters configuration, etc… and end up finding out from a bpo comment whether the behaviour you're observing is intentional or not.
History
Date User Action Args
2021-03-20 10:48:26xmorelsetrecipients: + xmorel, serhiy.storchaka
2021-03-20 10:48:26xmorelsetmessageid: <1616237306.46.0.916350152544.issue43526@roundup.psfhosted.org>
2021-03-20 10:48:26xmorellinkissue43526 messages
2021-03-20 10:48:25xmorelcreate