Opened 13 years ago

Last modified 13 years ago

#2825 defect new

reactors handle case where socket.fileno() returns -1

Reported by: Jean-Paul Calderone Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: therve Branch:
Author:

Description

At some point in Python's past, I'm pretty sure fileno() could actually return -1 sometimes. However, this hasn't been the case for a long, long time. The safe-guards this code is trying to provide is basically untested, or someone might have noticed when Python changed its behavior.

Now calling fileno() on a closed socket will raise an exception.

Change History (4)

comment:1 Changed 13 years ago by therve

Cc: therve added

I think the problem is that fileno is dynamically set to self.socket.fileno, but deleted in connectionLost, so we fallback to FileDescriptor.fileno, which does return -1. Maybe this default implementation should go away, and raises an exception instead.

comment:2 Changed 13 years ago by Jean-Paul Calderone

btw, I started to do some work in this area in the #1537 branch. Not sure if anything there is worth trying to use though.

comment:3 Changed 13 years ago by Glyph

For historical interest, Python used to return -1 from socket.fileno() in version 2.2. It was changed to be an exception in 2.3.

I don't really see the benefit of changing it to raise an exception. However, it would be nice if (A) this was tested to clearly demonstrate the case therve mentions, and (B) "-1" were a named constant instead.

comment:4 Changed 9 years ago by <automation>

Owner: Glyph deleted
Note: See TracTickets for help on using tickets.