Parity with https://hg.python.org/cpython/file/e106d9368bff/Objects/stringobject.c#l2763