Fix a bug when formatting str