[PyKDE] QIODevice.readBlock must return a tuple

Yann Cointepas yann at sapetnioc.org
Thu May 19 14:17:08 BST 2005


When subclassing QIODevice, I noticed (with a look at qiodevice.sip) that 
readBlock method must return a tuple with a string. I would expect this 
method to return a string. But my knowledge of sip/PyQt is not enough to say 
if it is a bug or not.

PyQT version: 3.14.1
sip version: 4.2.1

If you need to know why I used QIODevice:

I created the following (incomplete) QBuffer implementation in order to be 
able to use QWidgetFactory.createWidget() with the content of a *.ui file 
contained in a Python string.

class QBuffer( QIODevice ):
  def __init__( self, buffer ):
    QIODevice.__init__( self )
    self.__buffer = buffer
    self.open( IO_ReadOnly )

  def open( self, mode ):
    self.__io = StringIO( self.__buffer )
    return True

  def close( self ):
    self.__io.close()

  def flush( self ):
    self.__io.flush()

  def size( self ):
    return len( self.__buffer )

  def readAll( self ):
    return self.__io.read()

  def getch( self ):
    return self.__io.read( 1 )

  def readBlock( self, size ):
    result = self.__io.read( size )
    if result:
      return ( result, )
    return None

-- 
Yann Cointepas                         Tel: +33 1 69 86 78 52
CEA - SHFJ                             Fax: +33 1 69 86 77 86
4, place du Général Leclerc
91401 Orsay Cedex France




More information about the PyQt mailing list