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-131178: Fix mimetypes CLI docs to mention that errors go to stdout by htjworld · Pull Request #149683 · python/cpython Conversation
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Documentation build overview
63 files changed ·
|
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.
This is a rather hard problem: when docs do not represent the reality, we can either fix docs or fix the code.
I guess a lot of places already rely on the fact that errors and results are in the stdout, not in stderr.
So, I think that it would be better to change the docs.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| def test_type_lookup(self): | ||
| rc, stdout, stderr = assert_python_ok('-m', 'mimetypes', 'foo.pdf') | ||
| self.assertIn(b'application/pdf', stdout) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Why not asserting the full stdout contents?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| def test_type_lookup_unknown(self): | ||
| rc, stdout, stderr = assert_python_failure('-m', 'mimetypes', 'foo.unknownext12345') | ||
| self.assertEqual(stdout, b'') | ||
| self.assertIn(b'error:', stderr) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
And the same here: we can assert the full error response.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| has_error = False | ||
| for result in results: | ||
| if result.startswith("error: "): | ||
| print(result, file=sys.stderr, flush=True) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This is a behavior change, please revert it.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| @@ -0,0 +1,2 @@ | |||
| Fix :mod:`mimetypes` CLI to write error messages to stderr instead of stdout, | |||
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
And since we revert the behavior change, we need to remove this file as well :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Per sobolevn's review: revert the behavior change that routed error messages to stderr, as existing code may rely on stdout behavior. Instead update docs to accurately reflect that errors go to stdout. Also update tests to assert full output contents as suggested.
|
I have made the requested changes; please review again |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for making the requested changes! : please review the changes made to this pull request. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| def test_unknown_flag(self): | ||
| rc, stdout, stderr = assert_python_failure('-m', 'mimetypes', '--unknown-flag') | ||
| self.assertNotEqual(rc, 0) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
assert the output please :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| @@ -0,0 +1,2 @@ | |||
| Add subprocess-based tests for the :mod:`mimetypes` command-line interface, | |||
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
we don't add news for docs / tests only changes.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| def test_extension_flag(self): | ||
| rc, stdout, stderr = assert_python_ok('-m', 'mimetypes', '-e', 'image/jpeg') | ||
| self.assertIn(b'.jpg', stdout) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Let's use assertEqual here as well.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
thanks for the review appreciate it |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for making the requested changes! : please review the changes made to this pull request. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| def test_unknown_flag(self): | ||
| rc, stdout, stderr = assert_python_failure('-m', 'mimetypes', '--unknown-flag') | ||
| self.assertEqual(stdout, b'') | ||
| self.assertIn(b'error', stderr) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| self.assertIn(b'error', stderr) | |
| self.assertIn(b'error: unrecognized arguments: --unknown-flag', stderr) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
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.
Thanks!
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.
If CI passes, it LGTM ;-)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hi @sobolevn, gentle ping 🙂 — is there anything else needed on my end for this to move forward? Thanks! |
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.
…docs
Restore the original filename.pict / --lenient example and the
filename.xxx multi-input example. Keep only the genuinely-needed
fix: the error message string ("unknown extension of X" was never
emitted; the CLI prints "media type unknown for X").
There was an error while loading. Please reload this page.
Co-authored-by: sobolevn <[email protected]>
|
Thanks a lot! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thank you for the thorough review! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Sorry, @htjworld and @sobolevn, I could not cleanly backport this to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-150655 is a backport of this pull request to the 3.15 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-150656 is a backport of this pull request to the 3.14 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@htjworld can you please follow the instructions in #149683 (comment) and create a manual 3.13 backport? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@sobolevn, I looked into the 3.13 backport — the mimetypes CLI was reworked after 3.13, so the changes don't seem to apply cleanly:
Would it make sense to drop the needs backport to 3.13 label? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Then no - thanks for the investigation :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…tdout (GH-149683) (#150656) gh-131178: Fix mimetypes CLI docs, mention that errors go to stdout (GH-149683) (cherry picked from commit 2b94b92) Co-authored-by: htjworld <[email protected]> Co-authored-by: sobolevn <[email protected]>
…tdout (GH-149683) (#150655) gh-131178: Fix mimetypes CLI docs, mention that errors go to stdout (GH-149683) (cherry picked from commit 2b94b92) Co-authored-by: htjworld <[email protected]> Co-authored-by: sobolevn <[email protected]>
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.