mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
issue27186: add open/io.open; patch by Jelle Zijlstra
This commit is contained in:
parent
228c636908
commit
d62548afed
4 changed files with 65 additions and 21 deletions
|
@ -161,6 +161,8 @@ def open(file, mode="r", buffering=-1, encoding=None, errors=None,
|
|||
opened in a text mode, and for bytes a BytesIO can be used like a file
|
||||
opened in a binary mode.
|
||||
"""
|
||||
if not isinstance(file, int):
|
||||
file = os.fspath(file)
|
||||
if not isinstance(file, (str, bytes, int)):
|
||||
raise TypeError("invalid file: %r" % file)
|
||||
if not isinstance(mode, str):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue