Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #102570
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Exception handling for socket.error in Python 3.5/RStudio |
| Date | Sat, 6 Feb 2016 13:04:19 +1100 |
| Lines | 47 |
| Message-ID | <mailman.28.1454724261.2317.python-list@python.org> (permalink) |
| References | <1067e50c-bcbd-464e-8013-754bd66fda91@googlegroups.com> <e05d99b4-fbcf-40c8-8a25-e824d55ed912@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de QlRUBQQgNESVoq/Se9n5vg0VIEqcJ97i+Y53UclcoFDA== |
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'received:209.85.223': 0.03; 'subject:Python': 0.05; 'friday,': 0.07; 'socket': 0.07; 'cc:addr:python-list': 0.09; 'socket.error': 0.09; 'underlying': 0.09; 'python': 0.10; 'syntax': 0.13; '0):': 0.16; '2016': 0.16; 'chris,': 0.16; 'clause,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:209.85.223.173': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:handling': 0.16; 'suggested,': 0.16; 'syntaxerror:': 0.16; 'traceback.': 0.16; 'wrote:': 0.16; 'input': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; '2.x': 0.22; '3.x': 0.22; 'context.': 0.22; 'file:': 0.22; 'parse': 0.22; 'am,': 0.23; 'code,': 0.23; 'feb': 0.23; 'sat,': 0.23; 'second': 0.24; 'tried': 0.24; 'header :In-Reply-To:1': 0.24; 'script': 0.25; 'installed': 0.26; 'error': 0.27; 'message-id:@mail.gmail.com': 0.27; 'looks': 0.29; 'colon': 0.29; 'quoting': 0.29; 'subject:/': 0.30; 'you?': 0.30; 'code': 0.30; 'error.': 0.31; 'post': 0.31; 'posting': 0.32; 'getting': 0.33; 'problem': 0.33; 'changing': 0.34; 'except': 0.34; 'previous': 0.34; 'running': 0.34; 'add': 0.34; 'received:google.com': 0.35; 'next': 0.35; 'according': 0.36; 'but': 0.36; 'too': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'version': 0.38; 'received:209': 0.38; 'skip:p 20': 0.38; 'end': 0.39; 'test': 0.39; 'system.': 0.39; 'rather': 0.39; 'still': 0.40; 'your': 0.60; 'close': 0.61; 'press': 0.61; 'provide': 0.61; 'replying': 0.61; 'email addr:gmail.com': 0.62; 'to,': 0.63; 'here:': 0.63; 'latest': 0.64; 'worth': 0.67; 'sounds': 0.76; 'chrisa': 0.84; 'utc-7,': 0.84; 'to:none': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=ZwPqSyS7OHE23o2JIpjzjL7g85qVIjDzlYHSvncMhtI=; b=zQmWQ8ZdfbuM0yUCtu+i2anlFRk6zvurXeGFtfA6+/d9krRC4vJPJDJkW8GAcHcQlL x01uqUmzyAB6jMNyI5BDejeyhozMHRhD5GpQ+EZ+CZccJkkBQz2ZVTfpFsqyY89cxsO2 by5qVr29avhKE2PNJj85QBLmI9t0FIvs8X0NmU7Dh+dH1gpsorU6EXIGzfVJr48b2AyB gU1QPsJgmd4PSZKdQ1SKo63RkU7Ug7U18dTeP4r6otYzPd8QcPh/19zi3l4UTZ4f5y0d cBcCurZ9nReZMeXvepiwESGJX2snaI0dmvuA6ctyOWouTW/6vWOWKLXIL4gGfnlPK0k5 9oqg== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc:content-type; bh=ZwPqSyS7OHE23o2JIpjzjL7g85qVIjDzlYHSvncMhtI=; b=hzvh0hk94zBbZhLUFTlqixIxJZ0uyGteiaIj6BTHeojdwYtmT6QF0lyXN+vA4YjEu6 q6GZ/ArIkxqp6ChXH5L1xiGCo4+AJzA1xsn0KTwUcFrPh8Gp1bQbUUDOY0P7qS0bDEEg J3YyWvtMgaUdjhRZrcqYJqBRQSKWEBV2W031D2soSzr/IQjesO0pI08a1Q47QrCgbs2R b7omflu9JZJLX0QK5dJRge5967p1uEkOUv3D37dU3poUY/5msWtr5iZDwC+ScXKVI7QQ nCw1EZhWrNZ0ySHWQXFNH3EAwncW8T8q/cvlNVQR325VlDI9FQT7WcoCYNw36YF0KXpd Lb4Q== |
| X-Gm-Message-State | AG10YOQ3NL9LUuxkgcvXUx70Q3q1Ftzzi3UjolkatIR+9Jek3Ape7zvQNmToD8JZA36Awoiij93Lg0zKoD8ftw== |
| X-Received | by 10.107.40.76 with SMTP id o73mr16693921ioo.157.1454724259215; Fri, 05 Feb 2016 18:04:19 -0800 (PST) |
| In-Reply-To | <e05d99b4-fbcf-40c8-8a25-e824d55ed912@googlegroups.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21rc2 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:102570 |
Show key headers only | View raw
On Sat, Feb 6, 2016 at 9:35 AM, <shaunak.bangale@gmail.com> wrote:
> On Friday, February 5, 2016 at 12:58:37 PM UTC-7, shaunak...@gmail.com wrote:
>> I am running this python script on R-studio. I have Python 3.5 installed on my system.
>>
>> count = 10
>> while (count > 0):
>> try :
>> # read line from file:
>> print(file.readline())
>> # parse
>> parse_json(file.readline())
>> count = count - 1
>> except socket.error as e
>> print('Connection fail', e)
>> print(traceback.format_exc())
>>
>> # wait for user input to end
>> # input("\n Press Enter to exit...");
>> # close the SSLSocket, will also close the underlying socket
>> ssl_sock.close()
>> The error I am getting is here:
>>
>> line 53 except socket.error as e ^ SyntaxError: invalid syntax
>>
>> I tried changing socket.error to ConnectionRefusedError. and still got the same error.
>>
>> Please tell me if the problem is with Rstudio, Python version or the syntax.
>>
>> TIA
>> -Shaunak
>
>
> Chris,
>
> That sounds legitimate.
> But I never installed second 3.X version and deleted previous 2.X version and using only 3.5 now. What will be the next test according to you?
(Please quote the person you're replying to, rather than simply
quoting your own original post - it helps to provide context. Thanks!)
The next thing to try would be to add the colon at the end of the
"except" clause, as has already been suggested, and then to post the
latest code (preferably all of it - if it looks like too much, it's
worth shortening the code, rather than posting a snippet) and the full
traceback.
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Exception handling for socket.error in Python 3.5/RStudio shaunak.bangale@gmail.com - 2016-02-05 11:58 -0800
Re: Exception handling for socket.error in Python 3.5/RStudio Nathan Hilterbrand <nhilterbrand@gmail.com> - 2016-02-05 15:07 -0500
Re: Exception handling for socket.error in Python 3.5/RStudio shaunak.bangale@gmail.com - 2016-02-05 12:11 -0800
Re: Exception handling for socket.error in Python 3.5/RStudio shaunak.bangale@gmail.com - 2016-02-05 12:17 -0800
Re: Exception handling for socket.error in Python 3.5/RStudio "Martin A. Brown" <martin@linux-ip.net> - 2016-02-05 12:08 -0800
Re: Exception handling for socket.error in Python 3.5/RStudio shaunak.bangale@gmail.com - 2016-02-05 12:22 -0800
Re: Exception handling for socket.error in Python 3.5/RStudio "Martin A. Brown" <martin@linux-ip.net> - 2016-02-05 12:44 -0800
Re: Exception handling for socket.error in Python 3.5/RStudio "Martin A. Brown" <martin@linux-ip.net> - 2016-02-05 13:01 -0800
Re: Exception handling for socket.error in Python 3.5/RStudio Chris Angelico <rosuav@gmail.com> - 2016-02-06 08:01 +1100
Re: Exception handling for socket.error in Python 3.5/RStudio Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-02-05 19:08 -0200
Re: Exception handling for socket.error in Python 3.5/RStudio shaunak.bangale@gmail.com - 2016-02-05 13:26 -0800
Re: Exception handling for socket.error in Python 3.5/RStudio Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-02-05 19:37 -0200
Re: Exception handling for socket.error in Python 3.5/RStudio shaunak.bangale@gmail.com - 2016-02-05 13:57 -0800
Re: Exception handling for socket.error in Python 3.5/RStudio Chris Angelico <rosuav@gmail.com> - 2016-02-06 08:57 +1100
Re: Exception handling for socket.error in Python 3.5/RStudio shaunak.bangale@gmail.com - 2016-02-05 14:35 -0800
Re: Exception handling for socket.error in Python 3.5/RStudio Chris Angelico <rosuav@gmail.com> - 2016-02-06 13:04 +1100
Re: Exception handling for socket.error in Python 3.5/RStudio Shaunak Bangale <shaunak.bangale@gmail.com> - 2016-02-05 13:50 -0700
Re: Exception handling for socket.error in Python 3.5/RStudio Shaunak Bangale <shaunak.bangale@gmail.com> - 2016-02-05 14:00 -0700
Re: Exception handling for socket.error in Python 3.5/RStudio Shaunak Bangale <shaunak.bangale@gmail.com> - 2016-02-05 14:15 -0700
Re: Exception handling for socket.error in Python 3.5/RStudio dieter <dieter@handshake.de> - 2016-02-07 09:23 +0100
Re: Exception handling for socket.error in Python 3.5/RStudio shaunak.bangale@gmail.com - 2016-02-08 00:04 -0800
Re: Exception handling for socket.error in Python 3.5/RStudio shaunak.bangale@gmail.com - 2016-02-19 10:07 -0800
csiph-web