Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

> And though I did not check, I expect the `-b` flag exists mostly because of 
> the performance impact of the warning any time bytes are checked for 
> equality, but surely that impact would be limited and probably not very 
> relevant for the stringification of bytes and that could (eventually) be 
> moved out of the `-b` flag and to the regular warnings system?

If working Python 3 program suddenly became emitting BytesWarning it will 
confuse users.

Finally we will get rid of the -b option and BytesWarning. str() for bytes 
object will be equal to repr(), without warnings and errors. If you want to 
change it, use -b. Maybe introducing PYTHONBYTESWARNING will help. But I do not 
think we should change the behavior for these who do not ask for it specially 
if it will differ from the future behavior.

> Right but what about the ability to enable warning on stringification without 
> enabling the warning on comparison?

I think it would work. But it is significant amount of work (add corresponding 
C API, parsing and copying code, documentation, tests), and for small benefit. 
Would not be better to filter out warnings by message?

I think that adding PYTHONBYTESWARNING can help you.

----------
nosy: +methane, vstinner

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43526>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to