Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
methane merged 9 commits intopython:mainfrommethane:c-cleandoc
Jul 15, 2023

Conversation

methane
Copy link
Member

@methanemethane commentedJul 4, 2023
edited by github-actionsbot
Loading

@methane
Copy link
MemberAuthor

methane commentedJul 4, 2023
edited
Loading

# sqlalchemy/orm/__pycache__# main:ls -lS | head-rw-r--r--  1 inada-n  staff  197484 Jul  4 18:06 session.cpython-313.pyc-rw-r--r--  1 inada-n  staff  169161 Jul  4 18:06 mapper.cpython-313.pyc-rw-r--r--  1 inada-n  staff  137441 Jul  4 18:06 events.cpython-313.pyc-rw-r--r--  1 inada-n  staff  130456 Jul  4 18:06 relationships.cpython-313.pyc-rw-r--r--  1 inada-n  staff  128389 Jul  4 18:06 query.cpython-313.pyc-rw-r--r--  1 inada-n  staff  104012 Jul  4 18:06 strategies.cpython-313.pyc-rw-r--r--  1 inada-n  staff  101628 Jul  4 18:06 _orm_constructors.cpython-313.pyc-rw-r--r--  1 inada-n  staff  100939 Jul  4 18:06 context.cpython-313.pyc-rw-r--r--  1 inada-n  staff   98761 Jul  4 18:06 attributes.cpython-313.pyc# c-cleandoc:total 4432-rw-r--r--  1 inada-n  staff  187185 Jul  4 21:04 session.cpython-313.pyc-rw-r--r--  1 inada-n  staff  163634 Jul  4 21:04 mapper.cpython-313.pyc-rw-r--r--  1 inada-n  staff  127659 Jul  4 21:04 relationships.cpython-313.pyc-rw-r--r--  1 inada-n  staff  124634 Jul  4 21:04 events.cpython-313.pyc-rw-r--r--  1 inada-n  staff  119689 Jul  4 21:04 query.cpython-313.pyc-rw-r--r--  1 inada-n  staff  103889 Jul  4 21:04 strategies.cpython-313.pyc-rw-r--r--  1 inada-n  staff  100432 Jul  4 21:04 context.cpython-313.pyc-rw-r--r--  1 inada-n  staff   97329 Jul  4 21:04 attributes.cpython-313.pyc-rw-r--r--  1 inada-n  staff   96105 Jul  4 21:04 _orm_constructors.cpython-313.pyc
# file size of session.pyc>>> a,b=197484,187185>>> (a-b)*100/a5.215106033906545

lines = doc.expandtabs().split('\n')
except UnicodeError:
return None
else:
Copy link
MemberAuthor

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'
Copy link
MemberAuthor

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);
}
Copy link
Member

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.

Copy link
MemberAuthor

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(' '))
Copy link
MemberAuthor

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.

@methanemethane merged commit2566b74 intopython:mainJul 15, 2023
@methanemethane deleted the c-cleandoc branchJuly 15, 2023 10:33
@Eclips4Eclips4 mentioned this pull requestJul 17, 2023
@merwok
Copy link
Member

merwok commentedJul 24, 2023
edited
Loading

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!

Carreau added a commit to Carreau/ipython that referenced this pull requestDec 31, 2023
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.
Carreau added a commit to Carreau/ipython that referenced this pull requestDec 31, 2023
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.
Carreau added a commit to ipython/ipython that referenced this pull requestDec 31, 2023
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.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@gpsheadgpsheadgpshead left review comments

@merwokmerwokmerwok left review comments

@iritkatrieliritkatrieliritkatriel left review comments

@sunmy2019sunmy2019sunmy2019 left review comments

@markshannonmarkshannonAwaiting requested review from markshannonmarkshannon is a code owner

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@methane@merwok@gpshead@iritkatriel@sunmy2019@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp