parameters: ()
docstring: Open pty master and return (master_fd, tty_name).
      SGI and generic BSD version, for when openpty() fails.
docstring_summary: Open pty master and return (master_fd, tty_name).
      SGI and generic BSD version, for when openpty() fails.
docstring_tokens: Open pty master and return ( master_fd tty_name ) . SGI and generic BSD version for when openpty () fails .
function: def _open_terminal():
      """Open pty master and return (master_fd, tty_name).
      SGI and generic BSD version, for when openpty() fails."""
      try:
          import sgi
      except ImportError:
          pass
      else:
          try:
              tty_name, master_fd = sgi._getpty(os.O_RDWR, 0666, 0)
          except IOError, msg:
              raise os.error, msg
          return master_fd, tty_name
      for x in 'pqrstuvwxyzPQRST':
          for y in '0123456789abcdef':
              pty_name = '/dev/pty' + x + y
              try:
                  fd = os.open(pty_name, os.O_RDWR)
              except os.error:
                  continue
              return (fd, '/dev/tty' + x + y)
      raise os.error, 'out of pty devices'
function_tokens: def _open_terminal ( ) : try : import sgi except ImportError : pass else : try : tty_name , master_fd = sgi . _getpty ( os . O_RDWR , 0666 , 0 ) except IOError , msg : raise os . error , msg return master_fd , tty_name for x in 'pqrstuvwxyzPQRST' : for y in '0123456789abcdef' : pty_name = '/dev/pty' + x + y try : fd = os . open ( pty_name , os . O_RDWR ) except os . error : continue return ( fd , '/dev/tty' + x + y ) raise os . error , 'out of pty devices'