Are dicts supposed to raise comparison errors

Paul Moore p.f.moore at gmail.com
Wed Aug 1 11:22:16 EDT 2018


On Wed, 1 Aug 2018 at 16:10, Robin Becker <robin at reportlab.com> wrote:
>
> On 01/08/2018 14:38, Chris Angelico wrote:
> > t's a warning designed to help people port code from Py2 to Py3. It's
> > not meant to catch every possible comparison. Unless you are actually
> > porting Py2 code and are worried that you'll be accidentally comparing
> > bytes and text, just*don't use the -b switch*  and there will be no
> > problems.
> >
> > I don't understand what the issue is here.
>
> I don't either, I have never used the  -b flag until the issue was raised on bitbucket. If someone is testing a program with
> reportlab and uses that flag then they get a lot of warnings from this dictionary assignment. Probably the code needs tightening
> so that we insist on using native strings everywhere; that's quite hard for py2/3 compatible code.

They should probably use the warnings module to disable the warning in
library code that they don't control, in that case.

If they've reported to you that your code produces warnings under -b,
your response can quite reasonably be "thanks for the information,
we've reviewed our bytes/string handling and can confirm that it's
safe, so there's no fixes needed in reportlab".

Paul



More information about the Python-list mailing list