From 63fad4796bb4f1a843da9a9e5f57956b812b06c0 Mon Sep 17 00:00:00 2001 From: MinRK Date: Sun, 14 Nov 2010 21:43:36 -0800 Subject: [PATCH] Python version-independent int type check in poll closes gh-46 closes gh-48 --- zmq/core/poll.pyx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/zmq/core/poll.pyx b/zmq/core/poll.pyx index fe22aaad7..c7facf821 100644 --- a/zmq/core/poll.pyx +++ b/zmq/core/poll.pyx @@ -27,6 +27,7 @@ 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 @@ -34,6 +35,12 @@ 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) @@ -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