[issue12930] reindent.py inserts spaces in multiline literals

Jonathan Rogers report at bugs.python.org
Sun Jan 1 05:09:38 CET 2012

Jonathan Rogers <jonathanrrogers at gmail.com> added the comment:

I don't think reindent.py should change any bytes inside string literals since it can't know anything about what those strings mean or how they'll be used by the program at run time. Unfortunately, it starts out by unconditionally calling the .expandtabs() method on each input line, so tab characters are lost. The only change to a string literal I can imagine that would be safe is to replace tab characters with '\t'.

I am trying to use reindent.py on Python source files which include triple-quoted, multi-line string literals containing makefile and Python snippets. In both cases, running reindent.py changes the meaning of of that contained in the literal.

nosy: +Jonathan.Rogers

Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list