Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Shaunak Bangale Newsgroups: comp.lang.python Subject: Re: Exception handling for socket.error in Python 3.5/RStudio Date: Fri, 5 Feb 2016 14:15:50 -0700 Lines: 63 Message-ID: References: <1067e50c-bcbd-464e-8013-754bd66fda91@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de ZIvtiplWbxZ9am18ONWzFgExx7yMXgpxhPDJxKUV6Xtw== Return-Path: 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; 'subject:Python': 0.05; 'error:': 0.05; 'importerror:': 0.05; 'python3': 0.05; 'chunk': 0.07; 'username,': 0.07; 'cc:addr:python-list': 0.09; 'defined.': 0.09; 'ide': 0.09; 'nameerror:': 0.09; 'socket.error': 0.09; 'python': 0.10; 'syntax': 0.13; 'interpreter': 0.15; '2016': 0.16; '23,': 0.16; '_ssl': 0.16; 'initiation': 0.16; 'luck,': 0.16; 'pwd': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:handling': 0.16; 'to:addr:martin': 0.16; 'url:py': 0.16; 'wrote:': 0.16; '>': 0.18; 'shell': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'martin': 0.22; 'cc:no real name:2**0': 0.22; 'code.': 0.23; 'defined': 0.23; '(or': 0.23; 'feb': 0.23; 'bigger': 0.23; 'this:': 0.23; 'import': 0.24; '(most': 0.24; 'header:In-Reply-To:1': 0.24; 'command': 0.26; 'skip:" 20': 0.26; 'error': 0.27; 'coding': 0.27; 'fri,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'executing': 0.27; 'subject:/': 0.30; 'connection': 0.30; 'you?': 0.30; 'code': 0.30; 'skip:& 30': 0.30; 'error.': 0.31; 'certain': 0.31; 'getting': 0.33; 'run': 0.33; 'source': 0.33; 'traceback': 0.33; "skip:' 20": 0.34; 'file': 0.34; 'running': 0.34; 'received:google.com': 0.35; 'saved': 0.35; 'skip:> 10': 0.35; 'problem.': 0.35; 'reply.': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'skip:& 10': 0.37; 'there,': 0.37; 'thanks': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'skip:s 40': 0.38; 'sure': 0.39; 'still': 0.40; 'your': 0.60; 'close': 0.61; 'telling': 0.61; 'strictly': 0.64; 'online': 0.71; 'is)': 0.84; 'absolutely': 0.88 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=flK5H6krakYljzxlN6SKrYRWIbswtxSx5ybQeMhhGJ0=; b=XVRsmrKQtGmtw5D+JEbo6twZ2E8N8Hz/0WljbpCVRGstDbFbbI/YRXGDvh3oi0eVVK DwLJk8CsCwrRifiTeOFBUdOs9kiGMaRQN7ujhsU1nZjo1pfeeHItJpdBCo0NfvN+0IU7 7Vu3QstSepql8tMWxO31GcN6I4ppBTPBwybXu74zqeCtNbOCeTBpRl9WCIGPpHa3aN0n kZAfi4D9+yk4Mh3G0DcYY9MLORMUyxwcrEltC/vPtIVLB98LkojmK6okyJ4gudFSowKb B5UgVMDkxh8Zxo1ZrJmREIhqc/iZ+Ae1RsR8ybzOCWL54K77ZgVtUv6d1a1HQ+8cYFV6 N72Q== 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:from:date :message-id:subject:to:cc:content-type; bh=flK5H6krakYljzxlN6SKrYRWIbswtxSx5ybQeMhhGJ0=; b=YToc4Bqzz11X06+7VAyRkJTxMKIqZgC03ViTu/UqguKRN5V1y0M7a88g0aj7w9eato htgKSW5sT5m9Yto85kjAZRvMPhYqGP/YQmToufY/znXOTC0yftFwR3ZPsH6tXDtewqlG 5sAeNlKKxSDx+NeKi3hxX4cTxDfaIbCxBGM6UTvAWM+hGil8caySba/omXuzOZPfUjI0 JjHMN88savXLObt98ns8DCCHTyLbzREJqJMGQKBaQSAWhcKJVseS1KJUWqOT1u10FzSE 23QRPaL7n6Y837k/wZaBZn+wXCdQ0eCxT2Sm9J9kziwsLqt+4lxoUJPbhKY/73hadCwx ijLQ== X-Gm-Message-State: AG10YOTkhXo2RcBkE8fLO74cKvfxgSHxQ9MlGbjGUEJ5GImBLhtERP3Wd8SUynyH7UCrco2AJvqZMSYQKkK9Yw== X-Received: by 10.50.112.102 with SMTP id ip6mr17896113igb.88.1454706979824; Fri, 05 Feb 2016 13:16:19 -0800 (PST) In-Reply-To: X-Mailman-Approved-At: Sat, 06 Feb 2016 05:37:24 -0500 X-Content-Filtered-By: Mailman/MimeDel 2.1.21rc2 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc2 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:102579 I do have the initiation command defined. Just that I am not allowed to make the username, pwd public. I am absolutely sure I am running the same code. Now opened the same file with Python 3.5 shell and I get following error: from _ssl import RAND_status, RAND_egd, RAND_add ImportError: cannot import name 'RAND_egd' I am new to coding and this code has been borrowed from an online source but I can see same code working on mac+Rstudio+python combo. Salute your patience. Sincerely, On Fri, Feb 5, 2016 at 2:01 PM, Martin A. Brown wrote: > > Hi there, > > >Thanks for the detailed reply. I edited, saved and opened the file > >again. Still I am getting exactly the same error. > > > >Putting bigger chunk of code and the error again: > > [snipped; thanks for the larger chunk] > > >Error: > >except socket.error as e: > > ^ > >SyntaxError: invalid syntax > > I ran your code. I see this: > > $ python3 shaunak.bangale.py > Connecting... > Connection succeeded > Traceback (most recent call last): > File "shaunak.bangale.py", line 23, in > ssl_sock.write(bytes(initiation_command, 'UTF-8')) > NameError: name 'initiation_command' is not defined > > Strictly speaking, I don't think you are having a Python problem. > > * Are you absolutely certain you are (or your IDE is) executing > the same code you are writing? > > * How would you be able to tell? Close your IDE. Run the code on > the command-line. > > * How much time have you taken to work out what the interpreter is > telling you? > > Good luck, > > -Martin > > -- > Martin A. Brown > http://linux-ip.net/ > >