code: def read(self, size=None):
          # type: (Optional[int]) -> bytes
          '''
          A method to read and return up to size bytes.
  
          Parameters:
           size - Optional parameter to read size number of bytes; if None or
                  negative, all remaining bytes in the file will be read
          Returns:
           The number of bytes requested or the rest of the data left in the file,
           whichever is smaller.  If the file is at or past EOF, returns an empty
           bytestring.
          '''
          if not self._open:
              raise pycdlibexception.PyCdlibInvalidInput('I/O operation on closed file.')
  
          if self._offset >= self._length:
              return b''
  
          if size is None or size < 0:
              data = self.readall()
          else:
              readsize = min(self._length - self._offset, size)
              data = self._fp.read(readsize)
              self._offset += readsize
  
          return datf read(self, size=None):
          # type: (Optional[int]) -> bytes
          '''
          A method to read and return up to size bytes.
  
          Parameters:
           size - Optional parameter to read size number of bytes; if None or
                  negative, all remaining bytes in the file will be read
          Returns:
           The number of bytes requested or the rest of the data left in the file,
           whichever is smaller.  If the file is at or past EOF, returns an empty
           bytestring.
          '''
          if not self._open:
              raise pycdlibexception.PyCdlibInvalidInput('I/O operation on closed file.')
  
          if self._offset >= self._length:
              return b''
  
          if size is None or size < 0:
              data = self.readall()
          else:
              readsize = min(self._length - self._offset, size)
              data = self._fp.read(readsize)
              self._offset += readsize
  
          return data
docs: A method to read and return up to size bytes.
  
          Parameters:
           size - Optional parameter to read size number of bytes; if None or
                  negative, all remaining bytes in the file will be read
          Returns:
           The number of bytes requested or the rest of the data left in the file,
           whichever is smaller.  If the file is at or past EOF, returns an empty
           bytestring.