Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!81.171.88.16.MISMATCH!hq-usenetpeers.eweka.nl!hq-usenetpeers.eweka.nl!bcyclone03.am1.xlned.com!bcyclone03.am1.xlned.com!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '16,': 0.03; '480': 0.05; 'subsequent': 0.05; '340': 0.09; 'exception.': 0.09; 'indicates': 0.09; 'okay': 0.09; 'psf': 0.10; 'python': 0.11; '343': 0.16; '480,': 0.16; 'ah,': 0.16; 'e[0]': 0.16; 'errno': 0.16; 'mob:': 0.16; 'presume': 0.16; 'typeerror:': 0.16; '(0)': 0.16; 'wrote:': 0.18; 'module': 0.19; 'trying': 0.19; 'written': 0.21; 'header :User-Agent:1': 0.23; 'error': 0.23; 'faq': 0.24; 'module,': 0.24; 'specify': 0.24; 'helpful': 0.24; "i've": 0.25; 'header:In-Reply- To:1': 0.27; 'installed': 0.27; 'chris': 0.29; 'points': 0.29; 'see,': 0.30; "i'm": 0.30; 'code': 0.31; 'getting': 0.31; 'comments': 0.31; "skip:' 10": 0.31; 'equivalent.': 0.31; 'fault': 0.31; 'file': 0.32; 'this.': 0.32; 'probably': 0.32; 'interface': 0.32; 'run': 0.32; 'another': 0.32; 'older': 0.33; 'something': 0.35; 'there': 0.35; 'library.': 0.36; 'skip:" 50': 0.36; "didn't": 0.36; 'web,': 0.36; 'thanks': 0.36; 'possible': 0.36; 'level': 0.37; 'nov': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'does': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'skip:- 60': 0.39; 'according': 0.40; 'how': 0.40; 'read': 0.60; 'then,': 0.60; "you're": 0.61; 'address': 0.63; 'tel:': 0.63; 'myself': 0.63; 'teaching': 0.64; 'charset:windows-1252': 0.65; 'serial': 0.72; '0002': 0.84; '216': 0.84; 'believe,': 0.84; 'email name:peter': 0.84; 'philippines.': 0.84; 'subject:system': 0.84; 'from:addr:peter': 0.91; 'response,': 0.91 Date: Mon, 17 Nov 2014 12:10:45 +0800 From: Peter Bell User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Interrupted system call References: <54685C24.9040208@bellfamily.org.uk> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host.quksdns9.net X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - bellfamily.org.uk X-Get-Message-Sender-Via: host.quksdns9.net: authenticated_id: peter@bellfamily.org.uk X-Source: X-Source-Args: X-Source-Dir: X-Mailman-Approved-At: Mon, 17 Nov 2014 09:20:38 +0100 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 57 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1416212439 news.xs4all.nl 2836 [2001:888:2000:d::a6]:60426 X-Complaints-To: abuse@xs4all.nl X-Received-Body-CRC: 141436498 X-Received-Bytes: 6388 Xref: csiph.com comp.lang.python:80966 Many thanks for your helpful response, Chris. On 17/11/14 06:13, Chris Angelico wrote: > On Sun, Nov 16, 2014 at 7:11 PM, Peter Bell wrote: >> File "/usr/lib/python3.4/site-packages/serial/serialposix.py", line 480, >> in read >> if e[0] != errno.EAGAIN: >> TypeError: 'InterruptedError' object is not subscriptable >> ===================================================================== >> >> >> I'm not sure how to address the 'InterruptedError'. Can it/should it be >> masked at the user code level with a 'try:' block? Or is there another way >> to deal with it? > > At this stage, you're not getting it, because of the cascaded error, > so that's the thing to deal with. Okay - I was just thinking that if the 'InterruptedError' didn't occur, then the 'TypeError' would never be exposed! >> I presume that the subsequent error (TypeError) indicates some fault in the >> system level library. I'm not sure where/how to report this. > > Not system-level. According to the traceback, that's coming from line > 480 of something in site-packages, which probably means it was > installed with pip or equivalent. Do you know where you got hold of > this module from? That's who to report this to. Ah, I understand. I believe, then, that this is from the pyserial module, fetched from sourceforge. > It's trying to retrieve the errno from the exception. I suspect the > code was written for Python 2, and you're using it with Python 3. It's > probably possible to shorten/simplify the code somewhat. I see, now, that the sourceforge download does specify 'pyserial-2.7.tar.gz' and, yes, I'm working in Python 3. I see, from other comments around the web, that I'm not the only person to be attempting to use this module with 3. Given that pyserial is for 2.7, it is probably unreasonable to report errant behaviour when run on Python 3. I'm teaching myself (and the kids, as I go) Python and felt, rightly or wrongly, that it would be better to start with Python 3, rather than learning the older Python 2.x. Is there a better way to interface to a serial port from Python 3? I've found a reference in the PSF 3.3.6 FAQ which points to pyserial on sourceforge. -- ------------------------------------------------------------------- Peter Bell Mob: +63 (0) 9287 340 343 Tagum City, Philippines. Tel: +63 (0) 84 216 9037 email/msn: peter@bellfamily.org.uk Tel: +63 (0) 84 308 0002