This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: IDLE 'strip trailing whitespace' changes multiline strings
Type: behavior Stage: resolved
Components: IDLE Versions: Python 3.7, Python 3.6
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: bup, terry.reedy
Priority: normal Keywords:

Created on 2017-09-14 19:59 by bup, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg302204 - (view) Author: Dan Snider (bup) * Date: 2017-09-14 19:59
This function is supposed to be purely cosmetic. It just cleans up the junk whitespace commonly left behind when coding. But it could cause a problem when someone expects some string they defined to stay the same value, and then use that function and all of a sudden they have a crazy bug that you wouldn't even know how to find.
msg302274 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-09-15 16:40
The current behavior of IDLE's feature is standard, not a bug.  The cpython respository does not currently accept .py, .c, or .rst files with any trailing whitespace.  <pythondir>/tools/scripts/ strips trailing whitespace from all lines.  Notepad++, a widely used multi-language Windows programmer's editor, does the same.

I am aware of the potential surprise.  If one wants multiline strings with embedded trailing whitespace, one should avoid trailing whitespace strippers or use Python's string concatenation feature. 
>>> s = ('space \n' 'tab\t\n' 'line3\n')
>>> s
'space \ntab\t\nline3\n'

I am revising the doc to make the rstring behavior clearer.
Date User Action Args
2022-04-11 14:58:52adminsetgithub: 75658
2017-09-15 21:58:02terry.reedysetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-09-15 16:40:33terry.reedysettitle: IDLE 'strip trailing whitespace' changes the value of multiline strings -> IDLE 'strip trailing whitespace' changes multiline strings
stage: patch review
messages: + msg302274
versions: + Python 3.7
2017-09-14 19:59:30bupcreate