Merge lp:~adeuring/lp-dev-utils/select.error-withour-errno-attr into lp:lp-dev-utils

Proposed by Abel Deuring
Status: Merged
Approved by: j.c.sackett
Approved revision: 129
Merged at revision: 129
Proposed branch: lp:~adeuring/lp-dev-utils/select.error-withour-errno-attr
Merge into: lp:lp-dev-utils
Diff against target: 16 lines (+5/-1)
1 file modified
ec2test/ (+5/-1)
To merge this branch: bzr merge lp:~adeuring/lp-dev-utils/select.error-withour-errno-attr
Reviewer Review Type Date Requested Status
j.c.sackett (community) Approve
Review via email:

Description of the change

This morning I got an AttributeError while trying to start an EC2 test. The error occured in line 669 of ec2test/

    665 while 1:
    666 try:
    667[session], [], [], 0.5)
    668 except (IOError, select.error), e:
    669 if e.errno == errno.EINTR:
    670 continue

Poking around in the C source of the select module showed that select.error exceptions are always raised by calling PyErr_SetFromErrno(SelectError). (Well, OK, for Windows, another function is used, but I think we can ignore that here.) From the documentation of this function (

 "This is a convenience function to raise an exception when a C library function has returned an error and set the C variable errno. It constructs a tuple object whose first item is the integer errno value and whose second item is the corresponding error message..."

So, no attribute named "value". But e[0] is an integer with the value of the C errno variable.

I left the old attempt to access e.errno in the code because I don't know if some older version of Python may have generated a error object with the attribute errno.

To post a comment you must log in.
Revision history for this message
j.c.sackett (jcsackett) wrote :

Looks good. Thanks Abel.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ec2test/'
2--- ec2test/ 2012-08-07 07:15:13 +0000
3+++ ec2test/ 2012-09-26 10:04:19 +0000
4@@ -666,7 +666,11 @@
5 try:
6[session], [], [], 0.5)
7 except (IOError, select.error), e:
8- if e.errno == errno.EINTR:
9+ try:
10+ error_number = e.errno
11+ except AttributeError:
12+ error_number = e[0]
13+ if error_number == errno.EINTR:
14 continue
15 if session.recv_ready():
16 data = session.recv(4096)


People subscribed via source and target branches