scott-griffiths/bitstring

DeprecationWarning: invalid escape sequence in tests

Closed this issue · 1 comments

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> [

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.