#2491: os.fdopen() is now almost an alias to the builtin open(), and accepts the same parameters.

It just checks that the first argument is a file descriptor.
This commit is contained in:
Amaury Forgeot d'Arc 2008-08-01 00:06:49 +00:00
parent e19cadb427
commit bdbddf8a82
3 changed files with 11 additions and 11 deletions

View file

@ -651,9 +651,9 @@ class _wrap_close:
def __iter__(self):
return iter(self._stream)
# Supply os.fdopen() (used by subprocess!)
def fdopen(fd, mode="r", buffering=-1):
# Supply os.fdopen()
def fdopen(fd, *args, **kwargs):
if not isinstance(fd, int):
raise TypeError("invalid fd type (%s, expected integer)" % type(fd))
import io
return io.open(fd, mode, buffering)
return io.open(fd, *args, **kwargs)