PySide Bugzilla Closed for New Bugs

PySide is now a Qt Add-on and uses the Qt Project's JIRA Bug Tracker instead of this Bugzilla instance. This Bugzilla is left for reference purposes.

Bug 631 - QSocketNotifier: Accept file-like object (with .fileno() method) in constructor
: QSocketNotifier: Accept file-like object (with .fileno() method) in constructor
Status: CLOSED FIXED
Product: PySide
Classification: Unclassified
Component: QtCore
: HEAD
: All All
: P3 enhancement
Assigned To: Hugo Parente Lima
:
:
:
  Show dependency treegraph
 
Reported: 2011-01-20 19:08 EET by Thomas Perl
Modified: 2011-06-22 20:14 EEST (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Perl 2011-01-20 19:08:05 EET
The QSocketNotifier expects a file descriptor ID as the first parameter of its
constructor. This means, that for now, we have to use something like this:

QSocketNotifier(sys.stdin.fileno(), QSocketNotifier.Read)

To make this more Pythonic, I propose that the QSocketNotifier gets an
additional constructor that accepts a Python file-like object (i.e. any object
that has a .fileno() method that returns the file descriptor ID). Of course,
the old way of specifying the "socket" as integer should still be provided for
flexibility. This way, the socket notifier could be constructed like this:

QSocketNotifier(sys.stdin, QSocketNotifier.Read)

This could roughly look like this (skipping surrounding code for clarity):

def __init__(self, socket, type, parent=0):
    if hasattr(socket, 'fileno'):
       socket = socket.fileno()

    # .. normal code here ..
Comment 1 Matti Airas 2011-01-21 11:28:13 EET
Thanks for the proposal.

I think this would be an OK idea - it doesn't break existing APIs, it's very
unlikely to cause any future API clashes, and it would give some (if not great)
benefit to the developer.

However, since it's a rather minor issue, I'm prioritizing this P4. Patches are
welcome. ;-)
Comment 2 Matti Airas 2011-03-31 11:40:42 EEST
This was deprioritized to P4 because the bug was regarded as post-1.0 material.
Now that 1.0 has been published for one month already, I'd like to see this
bumped to P3.
Comment 3 Hugo Parente Lima 2011-06-03 00:21:43 EEST
Fixed in commit:

pyside/80c101172197fec4b05e8c56029ea13bb43820b0
Comment 4 renato filho 2011-06-22 20:14:05 EEST
release 1.0.4