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: wrong truncation of last line in cmd.Cmd
Type: behavior Stage: commit review
Components: Library (Lib) Versions: Python 3.1, Python 3.2, Python 2.7, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: r.david.murray Nosy List: catherine, eric.araujo, omatt, r.david.murray
Priority: normal Keywords: patch

Created on 2010-05-05 11:35 by omatt, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
cmd-noeol-test.patch r.david.murray, 2010-07-31 03:46
cmd-noeol-test.fix.patch catherine, 2010-08-01 00:40
cmd-noeol-test.fix.patch catherine, 2010-08-01 01:59
Messages (12)
msg105012 - (view) Author: Mattelaer (omatt) Date: 2010-05-05 11:35
When using the Cmd module on a file. 
it happens that the last line is truncated from the last caracther.

The problem is simply that it can happen that the last line doesn't finish by '\n' charcacter. In consequence the line which is suppose to suppress the '\n' suppress another character.

Cheers,

Olivier
msg105235 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-05-07 21:48
Setting version to 3.2, since this change would not be backward compatible and 2.7 is already in beta.
msg112184 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-07-31 19:26
Here is a unit test that demonstrates the problem (against py3k trunk).  I'm not convinced that fixing this would be backward incompatible.
msg112239 - (view) Author: Catherine Devlin (catherine) Date: 2010-08-01 00:40
Patch created live during PyOhio 2010 "Teach Me Python Bugfixing" session!
msg112241 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-08-01 00:50
Test runs okay on posix (linux2). Does the fix need to work with '\r\n' too?

Aside: Your patch has trailing spaces, you can spot them with good editor settings.
msg112242 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-08-01 00:51
Sorry, RDM is the actual culprit ;)
msg112255 - (view) Author: Catherine Devlin (catherine) Date: 2010-08-01 01:59
same patch, stripped of trailing spaces
msg112263 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-08-01 04:16
Éric: thanks for spotting the whitespace before I got smacked by the commit hook.  As for \r\n, our thought was that would be a feature (universal newline support), but upon reflection the current fix could actually break working code if by some weird chance someone is feeding \r terminated files to Cmd, while using \r\n should not break anything, since a \r\n terminated file would currently not work (since the \r would be left on the lines).  So I've changed the fix to strip '\r\n' in the commit (py3k r83380, 2.7 r83381, 2.5 r83382, 3.1 r83383).
msg112313 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-08-01 11:35
Universal newline mode helps when reading from stdin, but what I had in mind was actually <Enter> in cmd.exe putting CRLF. Re-reading the original report, I see this is not a concern, since the bug is about cmd used with a file only, not interactively, so my remark was moot.
msg112314 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-08-01 11:37
If “l” sorts after “a”, you’ve misplaced Catherine in ACKS. Funny how often this happens :)

(Cheers for the Teach Me session by the way Catherine!)
msg112408 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-08-01 23:58
Thanks, Éric. Fixed.
msg112425 - (view) Author: Mattelaer (omatt) Date: 2010-08-02 07:20
Thanks a lot for the fix.
On 02-août-10, at 01:58, R. David Murray wrote:

>
> R. David Murray <rdmurray@bitdance.com> added the comment:
>
> Thanks, Éric. Fixed.
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue8620>
> _______________________________________
History
Date User Action Args
2022-04-11 14:57:00adminsetgithub: 52866
2010-08-02 07:20:40omattsetmessages: + msg112425
2010-08-01 23:58:53r.david.murraysetmessages: + msg112408
2010-08-01 11:37:33eric.araujosetmessages: + msg112314
2010-08-01 11:35:15eric.araujosetmessages: + msg112313
2010-08-01 04:16:34r.david.murraysetstatus: open -> closed
versions: + Python 2.6, Python 3.1, Python 2.7
messages: + msg112263

assignee: r.david.murray
resolution: fixed
stage: needs patch -> commit review
2010-08-01 01:59:42catherinesetfiles: + cmd-noeol-test.fix.patch

messages: + msg112255
2010-08-01 00:51:25eric.araujosetmessages: + msg112242
2010-08-01 00:50:29eric.araujosetmessages: + msg112241
2010-08-01 00:40:32catherinesetfiles: + cmd-noeol-test.fix.patch
nosy: + catherine
messages: + msg112239

2010-07-31 19:26:20r.david.murraysetmessages: + msg112184
2010-07-31 19:25:58r.david.murraysetmessages: - msg112113
2010-07-31 03:46:51r.david.murraysetfiles: + cmd-noeol-test.patch
2010-07-31 03:45:34r.david.murraysetfiles: - cmd-noeol-test.patch
2010-07-31 03:44:59r.david.murraysetfiles: + cmd-noeol-test.patch

nosy: + r.david.murray
messages: + msg112113

keywords: + patch
stage: needs patch
2010-05-07 21:48:10eric.araujosettitle: wrong truncation of line in Cmd.cmd -> wrong truncation of last line in cmd.Cmd
nosy: + eric.araujo

messages: + msg105235

versions: + Python 3.2, - Python 2.6
components: + Library (Lib), - None
2010-05-05 11:35:54omattcreate