Interrupted system call
rosuav at gmail.com
Mon Nov 17 09:31:54 CET 2014
On Mon, Nov 17, 2014 at 3:10 PM, Peter Bell <peter at bellfamily.org.uk> wrote:
> 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 <peter at bellfamily.org.uk>
>>> File "/usr/lib/python3.4/site-packages/serial/serialposix.py", line
>>> in read
>>> if e != 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
>>> 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!
Correct. The handling of InterruptedError (a subclass of OSError) is
what's raising TypeError.
> Ah, I understand. I believe, then, that this is from the pyserial module,
> fetched from sourceforge.
> 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
> Given that pyserial is for 2.7, it is probably unreasonable to report errant
> behaviour when run on Python 3.
Yes and no. It may be possible to alter the code to be 2/3 compatible;
for instance, if e.errno is used instead of e, it should work in
both 2.7 and 3.x. (I haven't confirmed this, though.) But keep
> 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.
You felt rightly. All you need is...
> 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
... a solution to this. I would suggest looking on PyPI, the Python
Package Index, to see what you can get for Python 3. In your case, you
may well be in luck:
There's a version that claims to work with any Python version (though
there's some minor disagreement; the metadata says 2.3-2.7 and
3.0-3.3, but the Windows binaries say 2.4-2.7 and 3.0-3.4). I suspect
the "2.7" in the name is actually the version of PySerial, and it's
coincidental that that happens also to be a Python version.
Since you seem to be on a POSIX system, you shouldn't need to worry
about the provided binary installers. Use pip3 to install it for your
Python 3, and you should be all set.
Now, since the package does claim to support Python 3, any
discrepancies between that claim and the actual results you're seeing
*are* reportable bugs. But it's entirely possible that using pip to
install it will sort all that out, as it'll go and grab the correct
All the best!
More information about the Python-list