class_docstr: A base class providing the backwards-compatible spawn API for Pexpect.
  
  This should not be instantiated directly: use :class:`pexpect.spawn` or
  :class:`pexpect.fdpexpect.fdspawn`.
docstr: This reads at most "size" bytes from the file (less if the read hits
  EOF before obtaining size bytes). If the size argument is negative or
  omitted, read all data until EOF is reached. The bytes are returned as
  a string object. An empty string is returned when EOF is encountered
  immediately. 
docstr_tok: ["This","reads","at","most","``","size","''","bytes","from","the","file","(","less","if","the","read","hits","EOF","before","obtaining","size","bytes",")",".","If","the","size","argument","is","negative","or","omitted",",","read","all","data","until","EOF","is","reached",".","The","bytes","are","returned","as","a","string","object",".","An","empty","string","is","returned","when","EOF","is","encountered","immediately","."]
code: def read(self, size=-1):
      """This reads at most "size" bytes from the file (less if the read hits
      EOF before obtaining size bytes). If the size argument is negative or
      omitted, read all data until EOF is reached. The bytes are returned as
      a string object. An empty string is returned when EOF is encountered
      immediately."""
  
      if size == 0:
          return self.string_type()
      if size < 0:
          # delimiter default is EOF
          self.expect(self.delimiter)
          return self.before
  
      # I could have done this more directly by not using expect(), but
      # I deliberately decided to couple read() to expect() so that
      # I would catch any bugs early and ensure consistent behavior.
      # It's a little less efficient, but there is less for me to
      # worry about if I have to later modify read() or expect().
      # Note, it's OK if size==-1 in the regex. That just means it
      # will never match anything in which case we stop only on EOF.
      cre = re.compile(
          self._coerce_expect_string(".{%d}" % size), re.DOTALL
      )
      # delimiter default is EOF
      index = self.expect([cre, self.delimiter])
      if index == 0:
          ### FIXME self.before should be ''. Should I assert this?
          return self.after
      return self.before
  
imports: from io import StringIO, BytesIO
  import codecs
  import os
  import sys
  import re
  import errno
  from .exceptions import ExceptionPexpect, EOF, TIMEOUT
  from .expect import Expecter, searcher_string, searcher_re
label_desc: Use image node_id 15 for calling the SpawnBase obj's underlying member method code with example usage: obj.read(size) and returns: self, self, self, self