Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 422664a

Browse files
committed
Fix indentation problem with _asyncify
If the input to `_asyncify` contains newlines, the strategy of indenting and then truncating the first 8 characters won't work, since the first, empty line doesn't get indented. Instead I've changed the format string to accept the normal output of textwrap.indent() without modification.
1 parent b210342 commit 422664a

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

IPython/core/async_helpers.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ def _asyncify(code: str) -> str:
6969
And setup a bit of context to run it later.
7070
"""
7171
res = dedent(
72-
"""
73-
async def __wrapper__():
74-
try:
75-
{usercode}
76-
finally:
77-
locals()
7872
"""
79-
).format(usercode=indent(code, " " * 8)[8:])
73+
async def __wrapper__():
74+
try:
75+
{usercode}
76+
finally:
77+
locals()
78+
"""
79+
).format(usercode=indent(code, " " * 8))
8080
return res
8181

8282

0 commit comments

Comments
 (0)