summaryrefslogtreecommitdiff
path: root/Lib/cmd.py
diff options
context:
space:
mode:
authorR. David Murray <rdmurray@bitdance.com>2010-08-01 04:04:03 +0000
committerR. David Murray <rdmurray@bitdance.com>2010-08-01 04:04:03 +0000
commita5cdeaa5814063a52a0d3ca77ca05868ccf20218 (patch)
treed72dca556094ca9b1063c97b69f596efde2ad0a6 /Lib/cmd.py
parent351f5200e7446230ee9fa60789243f184ffabd98 (diff)
downloadcpython-a5cdeaa5814063a52a0d3ca77ca05868ccf20218.tar.gz
Merged revisions 83380 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r83380 | r.david.murray | 2010-07-31 23:31:09 -0400 (Sat, 31 Jul 2010) | 17 lines #8620: Cmd no longer truncates last character if stdin ends without newline Cmd used to blindly chop off the last character of every input line. If the input reached EOF and there was no final new line, it would truncate the last character of the last command. This fix instead strips trailing \r\n from the input lines. While this is a small behavior change, it should not break any working code, since feeding a '\r\n' terminated file to Cmd would previously leave the \r's on the lines, resulting in failed command execution. I wrote the unit test in preparation for a PyOhio TeachMe session run by Catherine Devlin, and we can thank Catherine and the PyOhio session attendees for the fix. I've added Catherine to the Acks file for organizing and leading the TeachMe session, out of which we will hopefully get some new contributors. ........
Diffstat (limited to 'Lib/cmd.py')
-rw-r--r--Lib/cmd.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/cmd.py b/Lib/cmd.py
index 5847f76360..29ea4608e7 100644
--- a/Lib/cmd.py
+++ b/Lib/cmd.py
@@ -137,7 +137,7 @@ class Cmd:
if not len(line):
line = 'EOF'
else:
- line = line[:-1] # chop \n
+ line = line.rstrip('\r\n')
line = self.precmd(line)
stop = self.onecmd(line)
stop = self.postcmd(stop, line)