diff options
author | Guido van Rossum <guido@python.org> | 2007-01-10 16:19:56 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-01-10 16:19:56 (GMT) |
commit | b940e113bf90ff71b0ef57414ea2beea9d2a4bc0 (patch) | |
tree | 0b9ea19eba1e665dac95126c3140ac2bc36326ad /Demo/sockets | |
parent | 893523e80a2003d4a630aafb84ba016e0070cbbd (diff) | |
download | cpython-b940e113bf90ff71b0ef57414ea2beea9d2a4bc0.zip cpython-b940e113bf90ff71b0ef57414ea2beea9d2a4bc0.tar.gz cpython-b940e113bf90ff71b0ef57414ea2beea9d2a4bc0.tar.bz2 |
SF patch 1631942 by Collin Winter:
(a) "except E, V" -> "except E as V"
(b) V is now limited to a simple name (local variable)
(c) V is now deleted at the end of the except block
Diffstat (limited to 'Demo/sockets')
-rwxr-xr-x | Demo/sockets/gopher.py | 10 | ||||
-rwxr-xr-x | Demo/sockets/telnet.py | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/Demo/sockets/gopher.py b/Demo/sockets/gopher.py index 2c46da6..0635ac1 100755 --- a/Demo/sockets/gopher.py +++ b/Demo/sockets/gopher.py @@ -142,7 +142,7 @@ def browser(*args): raise RuntimeError, 'too many args' try: browse_menu(selector, host, port) - except socket.error, msg: + except socket.error as msg: print 'Socket error:', msg sys.exit(1) except KeyboardInterrupt: @@ -202,7 +202,7 @@ def browse_textfile(selector, host, port): p = os.popen('${PAGER-more}', 'w') x = SaveLines(p) get_alt_textfile(selector, host, port, x.writeln) - except IOError, msg: + except IOError as msg: print 'IOError:', msg if x: x.close() @@ -213,7 +213,7 @@ def browse_textfile(selector, host, port): try: get_alt_textfile(selector, host, port, x.writeln) print 'Done.' - except IOError, msg: + except IOError as msg: print 'IOError:', msg x.close() @@ -311,7 +311,7 @@ def open_savefile(): cmd = savefile[1:].strip() try: p = os.popen(cmd, 'w') - except IOError, msg: + except IOError as msg: print repr(cmd), ':', msg return None print 'Piping through', repr(cmd), '...' @@ -320,7 +320,7 @@ def open_savefile(): savefile = os.path.expanduser(savefile) try: f = open(savefile, 'w') - except IOError, msg: + except IOError as msg: print repr(savefile), ':', msg return None print 'Saving to', repr(savefile), '...' diff --git a/Demo/sockets/telnet.py b/Demo/sockets/telnet.py index d50c37f..6bc9bcc 100755 --- a/Demo/sockets/telnet.py +++ b/Demo/sockets/telnet.py @@ -52,7 +52,7 @@ def main(): # try: s.connect((host, port)) - except error, msg: + except error as msg: sys.stderr.write('connect failed: ' + repr(msg) + '\n') sys.exit(1) # |