Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38142
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rodrick.brown@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'exception': 0.03; 'syntax': 0.03; 'elif': 0.04; 'debug': 0.05; 'socket': 0.05; 'sys': 0.05; 'except:': 0.07; 'try:': 0.07; 'python': 0.09; '0.1': 0.09; 'hostname': 0.09; 'port))': 0.09; 'sys.argv[0]': 0.09; 'sys.exit(2)': 0.09; 'subject:error': 0.11; '>>': 0.16; '1):': 0.16; '2.0:': 0.16; 'delay,': 0.16; 'pdb': 0.16; 'syntaxerror:': 0.16; 'true:': 0.16; 'to:name:python- list@python.org': 0.20; 'import': 0.21; '>': 0.23; 'raise': 0.24; 'skip:[ 10': 0.26; 'skip:# 10': 0.27; 'message- id:@mail.gmail.com': 0.27; 'interface': 0.27; 'this?': 0.28; 'address)': 0.29; 'socket,': 0.29; '8bit%:5': 0.29; 'skip:& 10': 0.29; 'figure': 0.30; 'file': 0.32; 'could': 0.32; 'print': 0.32; 'to:addr:python-list': 0.33; 'another': 0.33; 'skip:& 20': 0.33; 'received:google.com': 0.34; 'server': 0.35; 'data,': 0.35; 'received:209.85': 0.35; 'except': 0.36; 'client': 0.36; 'being': 0.37; 'why': 0.37; 'drop': 0.37; 'received:209': 0.37; 'data': 0.37; 'to:addr:python.org': 0.39; 'skip:" 10': 0.40; 'think': 0.40; 'address': 0.60; 'skip:u 10': 0.60; 'life': 0.66; 'address,': 0.79; '1060': 0.84; 'random,': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:from:date:message-id:subject:to :content-type; bh=HEtcQ0Hu6XndsfvHE8YtIWk5kW6HJ9GGHKa8MK7cQDc=; b=tUQMrRs8Aj7Odv3pTETKyjLRiuqDhoJ5K9BrqGfsXiB9UylCmB2/Rd/zrY7sJHjAqZ x8UgT9EESPJ/Lnw3AqAMGILkuf9ACNg7J+pZelGsT++kD7IYoXDFCLoB87fgWnZSB7oR VSL4Ik6edydaxhd/HwNP2FMqpVi3NsCM/UqweR5q1KhCtwoZZnlUMRXTL4SroLZFJCxB sXWASGXjq2nW6RJSZrPQURFtoRuzl4JbB95p8AlR7mNjNEXOT1WuV82XT1d2lkOP2Erc 3cwX1v0LOn+tvQ18IaUYxi4IMUXWHgqq9EZi6uNpcF/kKgeZVxlD+Ga3A39gr4Gjy1NA +ArQ== |
| X-Received | by 10.60.8.40 with SMTP id o8mr16386947oea.112.1360014607063; Mon, 04 Feb 2013 13:50:07 -0800 (PST) |
| MIME-Version | 1.0 |
| From | Rodrick Brown <rodrick.brown@gmail.com> |
| Date | Mon, 4 Feb 2013 16:49:37 -0500 |
| Subject | error in except |
| To | "python-list@python.org" <python-list@python.org> |
| Content-Type | multipart/alternative; boundary=e89a8ff1c7ea8b19b604d4ed1326 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1335.1360014616.2939.python-list@python.org> (permalink) |
| Lines | 117 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1360014616 news.xs4all.nl 6860 [2001:888:2000:d::a6]:55882 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:38142 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
For the life of me I cant figure out why this exception is being thrown.
How could I use pdb to debug this?
$ python udp_local2.py server
File "udp_local2.py", line 36
except:
^
SyntaxError: invalid syntax
#!/usr/bin/env python
import random, socket, sys
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
MAX = 65535
PORT = 1060
if 2 <= len(sys.argv) <= 3 and sys.argv[1] == 'server':
interface = sys.argv[2] if len(sys.argv) > 2 else ''
s.bind((interface, PORT))
print 'Listening at', s.getsockname()
while True:
data, address = s.recvfrom(MAX)
if random.randint(0, 1):
print 'The client at', address, 'says:', repr(data)
s.sendto('Your data was %d bytes' % len(data), address)
else:
print 'Pretending to drop packet from', address
elif len(sys.argv) == 3 and sys.argv[1] == 'client':
hostname = sys.argv[2]
s.connect((hostname, PORT))
print 'Client socket name is', s.getsockname()
delay = 0.1
while True:
s.send('This is another message')
print 'Waiting up to', delay, 'seconds for a reply'
s.settimeout(delay)
try:
data = s.recv(MAX)
except socket.timeout:
delay *= 2
if delay > 2.0:
raise RuntimeError('I think the server is down')
except:
raise
else:
break
print 'The server says', repr(data)
else:
print >> sys.stderr, 'usage: %d server [<interfae>]' % sys.argv[0]
print >> sys.stderr, ' or: %d client <host>' % sys.argv[0]
sys.exit(2)
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
error in except Rodrick Brown <rodrick.brown@gmail.com> - 2013-02-04 16:49 -0500
Re: error in except Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-05 09:21 +1100
Re: error in except John Evans <john.g.evans.ne@gmail.com> - 2013-02-04 17:37 -0500
csiph-web