svn+ssh://pythondev@svn.python.org/python/branches/release27-maint
................
r83381 | r.david.murray | 2010-08-01 00:04:03 -0400 (Sun, 01 Aug 2010) | 23 lines
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.
........
................
[ 924301 ] A leak case with cmd.py & readline & exception
by ensuring that the readline completion function is always reset
even in the case of an exception being raised. As a bonus, this
makes the documentation for pre & postloop accurate again.
This patch adds stdin, stdout as optional arguments to the cmd.Cmd
constructor (defaulting to sys.stdin, sys.stdout), and changes the Cmd
methods throughout to use self.stdout.write() and self.stdin.foo for
output and input. This allows much greater flexibility for using cmd -
for instance, hooking it into a telnet server.
Patch for library module and for documentation.
[ 676342 ] after using pdb readline does not work correctly
using Michael Stone's patch so the completer functionality of
cmd is only setup between preloop and postloop.
cmd.py uses raw_input(); eats SIGCLD:
I discovered a rather nasty side effect of the standard cmd.py
library today. If it's sitting inside raw_input(), any SIGCLDs that
get sent to your application get silently eaten and ignored. I'm
assuming that this is something that readline is thoughtfully doing
for me.
This patch adds an instance attr that allows the user to select to
not use raw_input(), but instead use sys.stdin.readline()
[Changed slightly to catch EOFError only for raw_input().]
added test script and expected output file as well
this closes patch 103297.
__all__ attributes will be added to other modules without first submitting
a patch, just adding the necessary line to the test script to verify
more-or-less correct implementation.
1. Comments at the beginning of the module, before
functions, and before classes have been turned
into docstrings.
2. Tabs are normalized to four spaces.
Also, removed the "remove" function from dircmp.py, which reimplements
list.remove() (it must have been very old).
The module cmd requires for each do_xxx command a help_xxx
function. I think this is a little old fashioned.
Here is a patch: use the docstring as help if no help_xxx
function can be found.
[I'm tempted to rip out all the help_* functions from pdb, but I'll
resist it. Any takers? --Guido]
cmd.py has incorporated the changes we discussed a couple of weeks ago
(a command queue, returning line from precmd, and stop from postcmd)
and some changes to help that were occasioned because I wanted to
inherit from pdb which inherits from cmd.py and the help routine
didn't look for commands or the associated help deeply enough.
1) I added a command queue which is helpful to me (at least so far) and
would also allow syntax like 's;s' (step; step) in conjunction with precmd
2) doc_leader allows the derived class to print a message before the help
output. Defaults to current practise of a blank line
3) nohelp allows one to override the 'No help on' message. I need
'Undefined command: "%s". Try "help".'
4) Pass line to self.precmd to allow one to do some parsing: change first
word to lower case, strip out a leading number, whatever.
5) Pass the result of onecmd and the input line to postcmd. This allows
one to ponder the stop result before it is effective.
6) emptyline() requires a if self.lastcmd: conditional because if the
first command is null (<cr>), you get an infinite recursion with the
code as it stands.
constructors. There is no backward compatibility. Not everything has
been tested.
* aiff.{py,doc}: deleted in favor of aifc.py (which contains its docs as
comments)
* calendar.py: remove stuff now built in time; some cleanup and
generalization in the calendar printing
* cmd.py: use __init__.
* tzparse.py: This module is no longer necessary -- use builtin time instead!
* changed eval() into getattr() in cmd.py
* added dirname(), basename() and (dummy) normath() to macpath.py
* renamed nntp.py to nntplib.py
* Made string.index() compatible with strop.index()
* Make string.atoi('') raise string.atoi_error rather than ValueError
* Added dirname() and normpath() to posixpath.