Are dicts supposed to raise comparison errors

Paul Moore p.f.moore at gmail.com
Wed Aug 1 14:00:27 EDT 2018


On Wed, 1 Aug 2018 at 18:43, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
>
> On Wed, 01 Aug 2018 16:22:16 +0100, Paul Moore wrote:
>
> > 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".
>
> I'm sorry, I don't understand this reasoning. (Perhaps I have missed
> something.) Robin says his code runs under both Python2 and Python3. He's
> getting a warning that the behaviour has changed between the two, and
> there's a dubious comparison being made between bytes and strings.
> Consequently, there's a very real chance that he has a dicts which have
> one key in Python 2 but two in Python 3:

Rightly or wrongly, I'm trusting Robin's assertion that he doesn't
believe there's a problem with his code. After all, the change in
behaviour between Python 2 and 3 has been explained a couple of times
in this thread, so I'm assuming Robin understands it, and is not
simply asserting unverified that he thinks his code is OK. Certainly,
if Robin hasn't checked that the warning isn't flagging an actual
issue with his code, then he should do so. Is that not obvious? If
it's not, then my apologies for assuming it was.

My point was that it's a *warning*, and as such it's perfectly
possible for a warning to *not* need addressing (other than to
suppress or ignore it once you're happy that doing so is the right
approach).

Paul



More information about the Python-list mailing list