Skip to content

Commit

Permalink
Python version-independent int type check in poll
Browse files Browse the repository at this point in the history
closes zeromqgh-46
closes zeromqgh-48
  • Loading branch information
minrk committed Nov 16, 2010
1 parent 359c6e9 commit 63fad47
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion zmq/core/poll.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,20 @@ from czmq cimport zmq_poll, zmq_pollitem_t
from socket cimport Socket
from allocate cimport allocate

import sys
from zmq.core.error import ZMQError
from zmq.core.constants import POLLIN,POLLOUT, POLLERR

#-----------------------------------------------------------------------------
# Polling related methods
#-----------------------------------------------------------------------------

# version-independent typecheck for int/long
if sys.version_info[0] >= 3:
int_t = int
else:
int_t = (int,long)

def _poll(sockets, long timeout=-1):
"""_poll(sockets, timeout=-1)
Expand Down Expand Up @@ -64,7 +71,7 @@ def _poll(sockets, long timeout=-1):
pollitems[i].socket = current_socket.handle
pollitems[i].events = events
pollitems[i].revents = 0
elif isinstance(s, (int,long)):
elif isinstance(s, int_t):
pollitems[i].socket = NULL
pollitems[i].fd = s
pollitems[i].events = events
Expand Down

0 comments on commit 63fad47

Please sign in to comment.