Raghuram Devarakonda added the comment:

I tested cmd.py on Linux and two things (including the one reported by
OP) looked odd to me.

1) CTRL-D produces a message "*** Unknown syntax: EOF". 
2) CTRL-C produces a KeyboardInterrupt exception and the session terminates.

I am attaching a patch that changes the behaviour to a more typical one
(at least, in IMHO). It terminates the session on CTRL-D and it just
ignores CTRL-C. Both of these can be overridden, if required. If the
patch is accepted, a doc change would be required in addition to the
change in doc string. I tested the patch on Linux and Windows.

----------
nosy: +draghuram
Added file: http://bugs.python.org/file8568/cmd.diff

__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1294>
__________________________________
Index: Lib/cmd.py
===================================================================
--- Lib/cmd.py	(revision 58221)
+++ Lib/cmd.py	(working copy)
@@ -130,6 +130,9 @@
                             line = raw_input(self.prompt)
                         except EOFError:
                             line = 'EOF'
+                        except KeyboardInterrupt:
+                            line = 'KeyboardInterrupt'
+
                     else:
                         self.stdout.write(self.prompt)
                         self.stdout.flush()
@@ -403,3 +406,13 @@
             for col in range(len(texts)):
                 texts[col] = texts[col].ljust(colwidths[col])
             self.stdout.write("%s\n"%str("  ".join(texts)))
+
+    def do_EOF(self, args):
+        """default implementation for EOF"""
+        self.stdout.write('\n')
+        return True
+
+    def do_KeyboardInterrupt(self, args):
+        """default implementation for CTRL-C"""
+        self.stdout.write('\n')
+        return False
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to