[Twisted-Python] error in pollreactor.py

Eric C. Newton ecn at metaslash.com
Sun Aug 31 16:48:47 EDT 2003

Method _dictRemove of pollreactor.py:

    def _dictRemove(self, selectable, mdict):
            # the easy way
            fd = reader.fileno()
            # the hard way: necessary because fileno() may disappear at any
            # moment, thanks to python's underlying sockets impl
            for fd, fdes in selectables.items():
                if selectable is fdes:
                # Hmm, maybe not the right course of action?  This method can't
                # fail, because it happens inside error detection...
        if mdict.has_key(fd):
            del mdict[fd]

First, "reader.fileno()" is just not going to work because there is no
variable "reader" in the scope.  This error is hidden by the
all-encompassing except clause.  Second, this comment about fileno()
disappearing... I don't believe it.  Does anyone know if this is
really true?

Code works (in my limited tests) if changed to:

    def _dictRemove(self, selectable, mdict):
        fd = selectable.fileno()
        if mdict.has_key(fd):
            del mdict[fd]


More information about the Twisted-Python mailing list