equal
deleted
inserted
replaced
436 if not self._oldios: |
436 if not self._oldios: |
437 return |
437 return |
438 nullfd = os.open(os.devnull, os.O_WRONLY) |
438 nullfd = os.open(os.devnull, os.O_WRONLY) |
439 ui = self.ui |
439 ui = self.ui |
440 for (ch, fp, fd), (cn, fn, mode) in zip(self._oldios, _iochannels): |
440 for (ch, fp, fd), (cn, fn, mode) in zip(self._oldios, _iochannels): |
441 newfp = getattr(ui, fn) |
|
442 # On Python 3, newfp is just a wrapper around fp even if newfp is |
|
443 # not fp, so deleting newfp is safe. |
|
444 if newfp is not fp: |
|
445 newfp.close() |
|
446 # restore original fd: fp is open again |
|
447 try: |
441 try: |
448 if newfp is fp and 'w' in mode: |
442 if 'w' in mode: |
449 # Discard buffered data which couldn't be flushed because |
443 # Discard buffered data which couldn't be flushed because |
450 # of EPIPE. The data should belong to the current session |
444 # of EPIPE. The data should belong to the current session |
451 # and should never persist. |
445 # and should never persist. |
452 os.dup2(nullfd, fp.fileno()) |
446 os.dup2(nullfd, fp.fileno()) |
453 fp.flush() |
447 fp.flush() |