class_docstr: Capture IO to/from a given os-level filedescriptor. 
docstr: save targetfd descriptor, and open a new
  temporary file there.  If no tmpfile is
  specified a tempfile.Tempfile() will be opened
  in text mode.
docstr_tok: ["save","targetfd","descriptor",",","and","open","a","new","temporary","file","there",".","If","no","tmpfile","is","specified","a","tempfile.Tempfile","(",")","will","be","opened","in","text","mode","."]
code: def __init__(self, targetfd, tmpfile=None, now=True, patchsys=False):
      """save targetfd descriptor, and open a new
      temporary file there.  If no tmpfile is
      specified a tempfile.Tempfile() will be opened
      in text mode.
      """
      self.targetfd = targetfd
      if tmpfile is None and targetfd != 0:
          f = tempfile.TemporaryFile("wb+")
          tmpfile = dupfile(f, encoding="UTF-8")
          f.close()
      self.tmpfile = tmpfile
      self._savefd = os.dup(self.targetfd)
      if patchsys:
          self._oldsys = getattr(sys, patchsysdict[targetfd])
      if now:
          self.start()
  
imports: import os
  import sys
  import py
  import tempfile
label_desc: Use image node_id 1 to create a new FDCapture object  with example: obj = FDCapture(targetfd, tmpfile, now, patchsys)