Ticket #4539 defect closed fixed
fileno() gets called on a ReadDescriptor after removing it from the reactor
|Reported by:||wulczer||Owned by:||exarkun|
(diff, github, buildbot, log)
The attached test case fails on HEAD twisted.
The use case is an object that wants to implement the IReadDescriptor interface and is getting added and removed to the reactor using reactor.addReader() and .removeReader().
More specifically, it is added to the reactor and after it becomes no longer usable (say, it has been closed by the user, or disposed in another way) and at which point fileno() can no longer return sensible values, it is removed from the reactor.
However fileno() still can get called on the object even after removing it from the reactor, hence the need to return, lacking any sensible values, -1 (the reason returning -1 works is explained in #2825, I believe). Since handling a -1 fileno is considered a crock (and rightfully so), this has to be considered a defect.