mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
bpo-26806: IDLE should run without docstrings (#14657)
After fcf1d00, IDLE startup failed with python compiled without docstrings.
This commit is contained in:
parent
3a3db970de
commit
6aeb2fe606
2 changed files with 19 additions and 8 deletions
|
|
@ -307,7 +307,12 @@ def fix_scaling(root):
|
|||
font['size'] = round(-0.75*size)
|
||||
|
||||
|
||||
def fixdoc(fun, text):
|
||||
tem = (fun.__doc__ + '\n\n') if fun.__doc__ is not None else ''
|
||||
fun.__doc__ = tem + textwrap.fill(textwrap.dedent(text))
|
||||
|
||||
RECURSIONLIMIT_DELTA = 30
|
||||
|
||||
def install_recursionlimit_wrappers():
|
||||
"""Install wrappers to always add 30 to the recursion limit."""
|
||||
# see: bpo-26806
|
||||
|
|
@ -329,19 +334,17 @@ def install_recursionlimit_wrappers():
|
|||
|
||||
return setrecursionlimit.__wrapped__(limit + RECURSIONLIMIT_DELTA)
|
||||
|
||||
setrecursionlimit.__doc__ += "\n\n" + textwrap.fill(textwrap.dedent(f"""\
|
||||
This IDLE wrapper adds {RECURSIONLIMIT_DELTA} to prevent possible
|
||||
uninterruptible loops.
|
||||
""").strip())
|
||||
fixdoc(setrecursionlimit, f"""\
|
||||
This IDLE wrapper adds {RECURSIONLIMIT_DELTA} to prevent possible
|
||||
uninterruptible loops.""")
|
||||
|
||||
@functools.wraps(sys.getrecursionlimit)
|
||||
def getrecursionlimit():
|
||||
return getrecursionlimit.__wrapped__() - RECURSIONLIMIT_DELTA
|
||||
|
||||
getrecursionlimit.__doc__ += "\n\n" + textwrap.fill(textwrap.dedent(f"""\
|
||||
This IDLE wrapper subtracts {RECURSIONLIMIT_DELTA} to compensate for
|
||||
the {RECURSIONLIMIT_DELTA} IDLE adds when setting the limit.
|
||||
""").strip())
|
||||
fixdoc(getrecursionlimit, f"""\
|
||||
This IDLE wrapper subtracts {RECURSIONLIMIT_DELTA} to compensate
|
||||
for the {RECURSIONLIMIT_DELTA} IDLE adds when setting the limit.""")
|
||||
|
||||
# add the delta to the default recursion limit, to compensate
|
||||
sys.setrecursionlimit(sys.getrecursionlimit() + RECURSIONLIMIT_DELTA)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue