GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-81283: compiler: remove indent from docstring by methane · Pull Request #106411 · python/cpython Conversation
|
|
Sorry, something went wrong.
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.
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.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| >>> 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.
The reason will be displayed to describe this comment to others. Learn more.
This change is needed to avoid dedenting output examples.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| Py_DECREF(doc); | ||
| return PyUnicode_FromStringAndSize(buff, w - buff); | ||
| } |
There was a problem 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.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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 except inspect.cleandoc.
If we reuse this logic in inspect.cleandoc, it would be:
doc = compiler.cleandoc(doc).strip('\n')
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| # 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.
The reason will be displayed to describe this comment to others. Learn more.
I changed from line.lstrip() to line.lstrip(' ') for better compatibility between inspect.cleandoc and compiler.cleandoc.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
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! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Since python/cpython#106411, it look like cpython is removing leading space and indent. We therefore need conditional check, until we decide Wether this is a problem we want to deal with or not.
Since python/cpython#106411, it look like cpython is removing leading space and indent. We therefore need conditional check, until we decide Wether this is a problem we want to deal with or not.
Since python/cpython#106411, it look like cpython is removing leading space and indent. We therefore need conditional check, until we decide Wether this is a problem we want to deal with or not.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.