messing with bytes I discover that this doesn't warn with python -b

########################
if __name__=='__main__':
    class nbytes(bytes):
        def __eq__(self,other):
            return bytes.__eq__(self,other) if isinstance(other,bytes) else 
False
        def __hash__(self):
            return bytes.__hash__(self)
    d={'a':1}
    d[nbytes(b'a')] = d['a']
    print(d)
    d={nbytes(b'a'):1}
    d['a'] = d[b'a']
    print(d)
########################


C:\code\hg-repos\reportlab\tmp>\python37\python -b tb1.py
{'a': 1, b'a': 1}
{b'a': 1, 'a': 1}

I expected one of the assignments to warn.
--
Robin Becker

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to