Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix BUG: Exception when PYTHONOPTIMIZE=2 #7434

Merged
merged 5 commits into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions python/cudf/cudf/core/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -7528,10 +7528,11 @@ def merge(left, right, *args, **kwargs):

# a bit of fanciness to inject docstring with left parameter
merge_doc = DataFrame.merge.__doc__
idx = merge_doc.find("right")
merge.__doc__ = "".join(
[merge_doc[:idx], "\n\tleft : DataFrame\n\t", merge_doc[idx:]]
)
if merge_doc is not None:
idx = merge_doc.find("right")
merge.__doc__ = "".join(
[merge_doc[:idx], "\n\tleft : DataFrame\n\t", merge_doc[idx:]]
)


def _align_indices(lhs, rhs):
Expand Down
35 changes: 18 additions & 17 deletions python/cudf/cudf/utils/docutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,24 @@ def docfmt(**kwargs):

def outer(fn):
buf = []
formatsiter = string.Formatter().parse(fn.__doc__)
for literal, field, fmtspec, conv in formatsiter:
assert conv is None
assert not fmtspec
buf.append(literal)
if field is not None:
# get indentation
lines = literal.rsplit("\n", 1)
if _only_spaces(lines[-1]):
indent = " " * len(lines[-1])
valuelines = kwargs[field].splitlines(True)
# first line
buf.append(valuelines[0])
# subsequent lines are indented
buf.extend([indent + ln for ln in valuelines[1:]])
else:
buf.append(kwargs[field])
if fn.__doc__ is not None:
shwina marked this conversation as resolved.
Show resolved Hide resolved
formatsiter = string.Formatter().parse(fn.__doc__)
for literal, field, fmtspec, conv in formatsiter:
assert conv is None
assert not fmtspec
buf.append(literal)
if field is not None:
# get indentation
lines = literal.rsplit("\n", 1)
if _only_spaces(lines[-1]):
indent = " " * len(lines[-1])
valuelines = kwargs[field].splitlines(True)
# first line
buf.append(valuelines[0])
# subsequent lines are indented
buf.extend([indent + ln for ln in valuelines[1:]])
else:
buf.append(kwargs[field])

fn.__doc__ = "".join(buf)
return fn
Expand Down