code: def chdir(self, dir, change_os_dir=0):
          
          curr=self._cwd
          try:
              if dir is not None:
                  self._cwd = dir
                  if change_os_dir:
                      os.chdir(dir.get_abspath())
          except OSError:
              self._cwd = curr
              raise
docs: Change the current working directory for lookups.
          If change_os_dir is true, we will also change the "real" cwd
          to match.