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.

classification
Title: IDLE: Include end newlines in whitespace fix.
Type: behavior Stage: resolved
Components: IDLE Versions: Python 3.9, Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: rhettinger, taleinat, terry.reedy
Priority: normal Keywords: patch

Created on 2019-11-20 06:06 by terry.reedy, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 17366 merged terry.reedy, 2019-11-24 03:17
PR 17370 closed miss-islington, 2019-11-24 21:29
PR 17371 closed miss-islington, 2019-11-24 21:29
PR 17379 merged terry.reedy, 2019-11-25 20:37
PR 17380 merged terry.reedy, 2019-11-25 20:42
Messages (6)
msg357030 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-11-20 06:06
Format => Strip Trailing Whitespace should strip extra newlines at the end of the file after stripping each line, and make sure that there is at least one.  The latter is done when saving, and that code can be reused.
msg357388 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-11-24 03:27
patchcheck.py removes even a single newline if that is all that remains after stripping each line.  So the revised rule is that a file should be either empty or end with a non-whitespace followed by a newline.  My intent is that a file be ready to merge to out github python/cpython repository.
msg357409 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-11-24 19:22
Currently, iomenu.IOBinding.fixnewlines makes sure that when a non-empty non-Shell file is saved (and possibly run), it ends with at least 1 newline.  At one time, I believe, compile needed this, and it is still good practice.  (Git diffs note the absence of a final newline.)

I originally planned to incorporate possible newline addition into do_rstrip, in anticipation of calling do_rstrip on save, but I have changed my mind, at least for the present.  That code can stay where it is.  If someone explicitly runs Strip Trailing Whitespace, adding a newline would sometimes be desired, but would sometimes be unexpected and possibly a nuisance.  do_rstrip will ensure that non-Shell files end with at most 1 newline.

My revised intent is that once we strip on save, saved files should be  properly formatted for use or merging into a repository.
msg357412 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-11-24 21:29
New changeset 6bf644ec82f14cceae68278dc35bafb00875efae by Terry Jan Reedy in branch 'master':
 bpo-38862: IDLE Strip Trailing Whitespace fixes end newlines  (GH-17366)
https://github.com/python/cpython/commit/6bf644ec82f14cceae68278dc35bafb00875efae
msg357545 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-11-27 01:12
New changeset 2fb971940b18bcf5a58b1b242b697d0f1d8ad7ef by Terry Jan Reedy in branch '3.7':
[3.7] bpo-38862: IDLE Strip Trailing Whitespace fixes end newlines  (GH-17366) (#17379)
https://github.com/python/cpython/commit/2fb971940b18bcf5a58b1b242b697d0f1d8ad7ef
msg357546 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-11-27 01:13
New changeset a9c86f5e1afa2487524b1947153953b583714d62 by Terry Jan Reedy in branch '3.8':
[3.8] bpo-38862: IDLE Strip Trailing Whitespace fixes end newlines  (GH-17366)
https://github.com/python/cpython/commit/a9c86f5e1afa2487524b1947153953b583714d62
History
Date User Action Args
2022-04-11 14:59:23adminsetgithub: 83043
2019-11-27 01:13:58terry.reedysetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-11-27 01:13:26terry.reedysetmessages: + msg357546
2019-11-27 01:12:59terry.reedysetmessages: + msg357545
2019-11-25 20:42:45terry.reedysetpull_requests: + pull_request16862
2019-11-25 20:37:57terry.reedysetpull_requests: + pull_request16861
2019-11-24 21:29:58miss-islingtonsetpull_requests: + pull_request16855
2019-11-24 21:29:52miss-islingtonsetpull_requests: + pull_request16854
2019-11-24 21:29:32terry.reedysetmessages: + msg357412
2019-11-24 19:22:54terry.reedysetnosy: + rhettinger, taleinat
messages: + msg357409
2019-11-24 03:27:20terry.reedysetmessages: + msg357388
2019-11-24 03:17:31terry.reedysetkeywords: + patch
stage: test needed -> patch review
pull_requests: + pull_request16851
2019-11-20 06:16:52terry.reedylinkissue33046 dependencies
2019-11-20 06:08:14terry.reedysettitle: IDLE: Include end whitespace in whitespace fix. -> IDLE: Include end newlines in whitespace fix.
2019-11-20 06:06:45terry.reedycreate