On Tue, Oct 27, 2020 at 5:23 AM Victor Stinner <vstinner@python.org> wrote:
os.get_exec_path() must modify temporarily warnings filters to ignore BytesWarning when it looks for 'PATH' (unicode) or b'PATH' (bytes) in the 'env' dictionary which may contain unicode or bytes strings. Modifying warnings filters impact all threads which is bad.
I dislike having to workaround this annoying behavior for dict lookup when -b or -bb is used.
Completely agree with you.
I'm quite sure that almost nobody uses -b or -bb when running their test suite or to develop. I expect that nobody uses it. According to replies, it seems like porting Python 2 code to Python 3 is the only use case. Python 3.9 and older can be used for that, no?
I think so. But I became a bit conservative when writing this proposal.
When can we remove it? My idea is:
3.10: Deprecate the -b option.
Do you mean writing a message into stderr? Or just deprecate it in the documentation?
I thought document only.
3.11: Make the -b option no-op. Bytes warning never emits. 3.12: Remove the -b option.
There is no _need_ to raise an error when -b is used. The -t option was kept even after the feature was removed (in Python 3.0 ?). -J ("used by Jython" says a comment) is a second command line option which is silently ignored.
I see.
BytesWarning will be deprecated in the document, but not to be removed.
I don't see what you mean here. I dislike the idea of deprecating a feature without scheduling its removal. I don't see the point of deprecating it in this case. I only see that as an annoyance.
Document only deprecation is useful for readers. Readers can know "I can just ignore this.".
I'm fine with removing the exception. If you don't plan to remove it, just leave it unchanged (not deprecated), no?
OK, my new proposal is: 3.10: Stop emitting BytesWarning for bytes == unicode case, because this is the most annoying part. 3.11: Stop emitting BytesWarning in core and stdlib. 4.0: Remove `-b` option, `sys.flags.bytes_warning`, and `BytesWarning`. Regards, -- Inada Naoki <songofacandy@gmail.com>