mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
#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:
parent
e19cadb427
commit
bdbddf8a82
3 changed files with 11 additions and 11 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue