Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.4k
gh-81283: compiler: remove indent from docstring#106411
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
methane commentedJul 4, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
|
lines = doc.expandtabs().split('\n') | ||
except UnicodeError: | ||
return None | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I removed this try-except-else block because Python 3 don't autodecode from bytes.
If doc is bytes,doc.split('\n')
raises TypeError, not UnicodeError.
@@ -1287,14 +1287,14 @@ def optionflags(): r""" | |||
treated as equal: | |||
>>> def f(x): | |||
... '>>> print(1, 2, 3)\n 1 2\n 3' | |||
... '\n>>> print(1, 2, 3)\n 1 2\n 3' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This change is needed to avoid dedenting output examples.
Py_DECREF(doc); | ||
return PyUnicode_FromStringAndSize(buff, w - buff); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I'm not sure the dedent logic belongs in compile.c.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Because this dedent logic is very specific for docstring.
We can not use this logic in other place exceptinspect.cleandoc
.
If we reuse this logic ininspect.cleandoc
, it would be:
doc=compiler.cleandoc(doc).strip('\n')
# Find minimum indentation of any non-blank lines after first line. | ||
margin = sys.maxsize | ||
for line in lines[1:]: | ||
content = len(line.lstrip(' ')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I changed fromline.lstrip()
toline.lstrip(' ')
for better compatibility between inspect.cleandoc and compiler.cleandoc.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Éric <merwok@netwok.org>
Uh oh!
There was an error while loading.Please reload this page.
merwok commentedJul 24, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
With the forum discussion ongoing, and the other discussion about requiring reviews, I think this could have waited a little bit to get a review approval. On the other hand it’s not a huge change! |
Sincepython/cpython#106411, it look likecpython is removing leading space and indent.We therefore need conditional check, until we decide Wether this is aproblem we want to deal with or not.
Sincepython/cpython#106411, it look likecpython is removing leading space and indent.We therefore need conditional check, until we decide Wether this is aproblem we want to deal with or not.
Sincepython/cpython#106411, it look likecpython is removing leading space and indent.We therefore need conditional check, until we decide Wether this is aproblem we want to deal with or not.
Uh oh!
There was an error while loading.Please reload this page.
📚 Documentation preview 📚:https://cpython-previews--106411.org.readthedocs.build/