scott-griffiths / bitstring

A Python module to help you manage your bits
https://bitstring.readthedocs.io/en/stable/index.html
MIT License
401 stars 67 forks source link

DeprecationWarning: invalid escape sequence in tests #327

Closed kitterma closed 2 months ago

kitterma commented 2 months ago

When running the 4.2.1 test suite I get the following warning with both python3.11 and python3.12:

tests/test_bits.py:739: DeprecationWarning: invalid escape sequence '\]' assert remove_unprintable(s.getvalue()) == """<Bits, fmt='bytes', length=2048 bits> [

scott-griffiths commented 2 months ago

Thanks for the (future) bug report!

Yes, I guess that's technically going to be a problem in Python 3.13 or later. The fix is just to remove \ from the characters that can be printed for the bytes interpretation when pretty-printing. Slightly backward incompatible, but I don't think anyone is relying on the output of pp and the work-arounds are likely to cause more problems.