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.

Author jaraco
Recipients eric.araujo, jaraco, orsenthil, pitrou
Date 2011-07-25.13:56:40
SpamBayes Score 1.7598846e-06
Marked as misclassified No
Message-id <1311602201.71.0.784938961409.issue10639@psf.upfronthosting.co.za>
In-reply-to
Content
I looked into the possibility of retaining newline characters even for files with mixed newlines, but I've decided that's too intrusive an approach. The current implementation specifically takes measures to strip whitespaces from the ends of lines, so it seems outside the scope of this bug to alter that behavior.

So I've taken another stab at a more robust implementation that does newline detection but raises an error if the file contains mixed newlines.

Furthermore, it adds an option (--newline) to specify which newline character to use, bypassing the mixed-newline error and allowing the user to override newline detection.

Here's a demo run:

    PS C:\cpython-issue10639> python .\Tools\scripts\reindent.py .\foo.py
    .\foo.py: mixed newlines detected; cannot continue without --newline
    PS C:\cpython-issue10639> python .\Tools\scripts\reindent.py --newline CRLF .\foo.py
    PS C:\cpython-issue10639> python .\Tools\scripts\reindent.py --newline LF .\foo.py
    PS C:\cpython-issue10639> python .\Tools\scripts\reindent.py .\foo.py

I've published this change as https://bitbucket.org/jaraco/cpython-issue10639/changeset/900df5732f93.

Please review. If this changeset is acceptable, I will push the revisions to the master repo. Please advise if I may also backport to Python 3.2 and 2.7.
History
Date User Action Args
2011-07-25 13:56:41jaracosetrecipients: + jaraco, orsenthil, pitrou, eric.araujo
2011-07-25 13:56:41jaracosetmessageid: <1311602201.71.0.784938961409.issue10639@psf.upfronthosting.co.za>
2011-07-25 13:56:41jaracolinkissue10639 messages
2011-07-25 13:56:40jaracocreate