bpo-8256: Fixed possible failing or crashing input()#517
bpo-8256: Fixed possible failing or crashing input()#517serhiy-storchaka merged 4 commits intopython:masterfrom
Conversation
if attributes "encoding" or "errors" of sys.stdin or sys.stdout are not set or are not strings.
|
@serhiy-storchaka, thanks for your PR! By analyzing the history of the files in this pull request, we identified @ncoghlan, @Haypo, @rhettinger, @loewis and @vadmium to be potential reviewers. |
vstinner
left a comment
There was a problem hiding this comment.
LGTM, but I didn't test the change.
Python/bltinmodule.c
Outdated
| if (!stdin_encoding || !stdin_errors) | ||
| if (!stdin_encoding || !stdin_errors || | ||
| !PyUnicode_Check(stdin_encoding) || | ||
| !PyUnicode_Check(stdin_errors)) |
There was a problem hiding this comment.
Isn’t this already covered by the PyUnicode_AsUTF8 (aka _PyUnicode_AsString in 3.5) error checking below?
Also, I would use a double indent here to distinguish the “if” condition from the body.
There was a problem hiding this comment.
This is the main point of this change. If PyUnicode_AsUTF8() is failed due to memory error or unpaired surrogates, this is an error. But if encoding or error are not strings (but None for example), use the fallback.
Python/bltinmodule.c
Outdated
| if (!stdin_encoding || !stdin_errors) | ||
| if (!stdin_encoding || !stdin_errors || | ||
| !PyUnicode_Check(stdin_encoding) || | ||
| !PyUnicode_Check(stdin_errors)) |
There was a problem hiding this comment.
This is the main point of this change. If PyUnicode_AsUTF8() is failed due to memory error or unpaired surrogates, this is an error. But if encoding or error are not strings (but None for example), use the fallback.
Python/bltinmodule.c
Outdated
|
|
||
| fallback: | ||
| /* Fallback if we're not interactive */ | ||
| PyErr_Clear(); |
There was a problem hiding this comment.
Hmm, need to clear references here.
if attributes "encoding" or "errors" of sys.stdin or sys.stdout are not set or are not strings. (cherry picked from commit c2cf128)
if attributes "encoding" or "errors" of sys.stdin or sys.stdout are not set or are not strings. (cherry picked from commit c2cf128)
if attributes "encoding" or "errors" of sys.stdin or sys.stdout are not set or are not strings. (cherry picked from commit c2cf128)
if attributes "encoding" or "errors" of sys.stdin or sys.stdout are not set or are not strings. (cherry picked from commit c2cf128)
Bumps [sentry-sdk](https://github.com/getsentry/sentry-python) from 1.5.2 to 1.5.4. - [Release notes](https://github.com/getsentry/sentry-python/releases) - [Changelog](https://github.com/getsentry/sentry-python/blob/master/CHANGELOG.md) - [Commits](getsentry/sentry-python@1.5.2...1.5.4) --- updated-dependencies: - dependency-name: sentry-sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Mariatta Wijaya <Mariatta@users.noreply.github.com>
if attributes "encoding" or "errors" of sys.stdin or sys.stdout
are not set or are not strings.