diff --git a/py/io/capture.py b/py/io/capture.py index 40e8f7646..695da63fc 100644 --- a/py/io/capture.py +++ b/py/io/capture.py @@ -72,3 +72,4 @@ def callcapture(func, *args, **kwargs): finally: out, err = so.reset() return res, out, err + diff --git a/py/io/dupfile.py b/py/io/dupfile.py index 8a927af58..d272ce42d 100644 --- a/py/io/dupfile.py +++ b/py/io/dupfile.py @@ -2,6 +2,14 @@ import os def dupfile(f, mode=None, buffering=0, raising=False): + """ return a new open file object that's a duplicate of f + + mode is duplicated if not given, buffering controls + buffer size (defaulting to no buffering) and raising + defines whether an exception is raised when an incompatible + file object is passed in (if raising is False, the file + object itself will be returned) + """ try: fd = f.fileno() except AttributeError: @@ -11,3 +19,4 @@ def dupfile(f, mode=None, buffering=0, raising=False): newfd = os.dup(fd) mode = mode and mode or f.mode return os.fdopen(newfd, mode, buffering) +