mirror of https://github.com/python/cpython
Added descriptor for builtins.open.__doc__
Before the change help(open) didn't return anything helpful but the doc string of io.OpenWrapper. Now it shows the user the documentation of io.open.
This commit is contained in:
parent
895627ff27
commit
a33eb06e3b
10
Lib/io.py
10
Lib/io.py
|
@ -189,6 +189,14 @@ def open(file, mode="r", buffering=None, encoding=None, errors=None,
|
||||||
text.mode = mode
|
text.mode = mode
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
class _DocDescriptor:
|
||||||
|
"""Helper for builtins.open.__doc__
|
||||||
|
"""
|
||||||
|
def __get__(self, obj, typ):
|
||||||
|
return (
|
||||||
|
"open(file, mode='r', buffering=None, encoding=None, "
|
||||||
|
"errors=None, newline=None, closefd=True)\n\n" +
|
||||||
|
open.__doc__)
|
||||||
|
|
||||||
class OpenWrapper:
|
class OpenWrapper:
|
||||||
"""Wrapper for builtins.open
|
"""Wrapper for builtins.open
|
||||||
|
@ -198,6 +206,8 @@ class OpenWrapper:
|
||||||
|
|
||||||
See initstdio() in Python/pythonrun.c.
|
See initstdio() in Python/pythonrun.c.
|
||||||
"""
|
"""
|
||||||
|
__doc__ = _DocDescriptor()
|
||||||
|
|
||||||
def __new__(cls, *args, **kwargs):
|
def __new__(cls, *args, **kwargs):
|
||||||
return open(*args, **kwargs)
|
return open(*args, **kwargs)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue