-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
bpo-31292: Fix distutils check --restructuredtext for include directives #3248
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
Conversation
Lib/distutils/tests/test_check.py
Outdated
| self.assertEqual(cmd._warnings, 0) | ||
|
|
||
| # check that includes work to test #31292 | ||
| metadata['long_description'] = f'title\n=====\n\n.. include:: {os.devnull}' |
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.
Could you use explicit formatting, so that backporting the fix becomes easier?
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.
sure, will do in a second.
Lib/distutils/command/check.py
Outdated
| def _check_rst_data(self, data): | ||
| """Returns warnings when the provided data doesn't compile.""" | ||
| source_path = StringIO() | ||
| source_path = self.distribution.script_name or 'long_description' |
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.
Do you think it would be better to have a name looking like <something>, to hint that this is not a real filename?
(I forget which stdlib module uses <stdin> but I like the convetion)
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 like the convetion
me too! the rST data is always retrieved via self.distribution.get_long_description(), so some variant of long_description seems to be most informative to me.
maybe something like this?
source_path = '<long_description>'
if self.distribution.script_name:
source_path = '{} {}'.format(self.distribution.script_name, source_path)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.
That depends if source_path has to be a path-like string, or arbitrary text.
I see your point that a warning or error message saying only «setup.py: bad include bla bla» may not be enough to let the user understand that the issue is reST in long_description, especially if the text is read from a README or other file.
If source_path is for human display only and doesn’t have to look like a file path, then +1 to your idea, maybe with parens rather than brackets: setup.py (long_description) / fallback distutils (long_description)
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.
at multiple points the attribute docs say something like “Path to or description of the input source being processed”, which makes me assume that free-form text is OK.
Lib/distutils/command/check.py
Outdated
|
|
||
| document = nodes.document(settings, reporter, source=source_path) | ||
| document.note_source(source_path, -1) | ||
| document.note_source(StringIO(), -1) |
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.
What does note_source do?
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.
it sets current_source and current_line, the former also being “Path to or description of the input source being processed”
will change
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.
Would it be easy to add a test for this too? @flying-sheep
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.
so distutils went against this recommendation and instantiates the class directly.
new_document does exactly the same thing except that it also creates a noisy reporter instead of a silent one, so i think we can skip a test here.
note that decode_path is just something like ensure_unicode and while new_document talks of paths, the document class says “Path to or description of the input source being processed”
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.
Ok but I would just like to be sure about what the change does. Is the source_path used in the error message or warning text maybe? Even without a unit test, does the command-line output make sense for a human reader?
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.
@flying-sheep ping
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.
sorry for the delay! i looked into it, and it needs to be a path after all if you use a relative path for a include or csv_table directive. i adjusted the test accordingly
|
I’m not sure that Travis or buildbots have docutils installed to test things, but I assume you tested locally. Thanks for the patch! LGTM |
|
yup, sure did. thanks for the quick and pleasant review process! |
merwok
left a comment
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.
One question left
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
Answered above. I didn't expect the Spanish Inquisition! |
|
Nobody expects the Spanish Inquisition! @merwok: please review the changes made to this pull request. |
|
|
||
|
|
||
| HERE = Path(__file__).parent | ||
| INCLUDE_TEST_PATH = (HERE / 'includetest.rst').relative_to(Path.cwd()) |
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.
Would you mind using os.path functions to make it easier to backport the patch?
| # check that includes work to test #31292 | ||
| metadata['long_description'] = 'title\n=====\n\n.. include:: {}'.format(INCLUDE_TEST_PATH) | ||
| cmd = self._run(metadata, strict=1, restructuredtext=1) | ||
| self.assertEqual(cmd._warnings, 0) |
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.
Is it possible to test the value of the long description (to see the desired text included)?
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
I didn’t notice that the PR was for 3.6. Could you rebase the changes for master? |
|
@flying-sheep Thanks for the PR. As @merwok noted earlier, the PR needs to be based against the cpython "master" branch, not the "3.6" branch. As I don't think there is any practical way to modify the existing PR, I'm closing this one; please resubmit a new PR against master. Thanks! |
https://bugs.python.org/issue31292