Skip to content

bpo-8256: Fixed possible failing or crashing input()#517

Merged
serhiy-storchaka merged 4 commits intopython:masterfrom
serhiy-storchaka:bpo-8256-input-fallback
Mar 12, 2017
Merged

bpo-8256: Fixed possible failing or crashing input()#517
serhiy-storchaka merged 4 commits intopython:masterfrom
serhiy-storchaka:bpo-8256-input-fallback

Conversation

@serhiy-storchaka
Copy link
Copy Markdown
Member

if attributes "encoding" or "errors" of sys.stdin or sys.stdout
are not set or are not strings.

if attributes "encoding" or "errors" of sys.stdin or sys.stdout
are not set or are not strings.
@mention-bot
Copy link
Copy Markdown

@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.

Copy link
Copy Markdown
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I didn't test the change.

if (!stdin_encoding || !stdin_errors)
if (!stdin_encoding || !stdin_errors ||
!PyUnicode_Check(stdin_encoding) ||
!PyUnicode_Check(stdin_errors))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

if (!stdin_encoding || !stdin_errors)
if (!stdin_encoding || !stdin_errors ||
!PyUnicode_Check(stdin_encoding) ||
!PyUnicode_Check(stdin_errors))
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.


fallback:
/* Fallback if we're not interactive */
PyErr_Clear();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, need to clear references here.

@serhiy-storchaka serhiy-storchaka merged commit c2cf128 into python:master Mar 12, 2017
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Mar 12, 2017
if attributes "encoding" or "errors" of sys.stdin or sys.stdout
are not set or are not strings.

(cherry picked from commit c2cf128)
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Mar 12, 2017
if attributes "encoding" or "errors" of sys.stdin or sys.stdout
are not set or are not strings.

(cherry picked from commit c2cf128)
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Mar 12, 2017
if attributes "encoding" or "errors" of sys.stdin or sys.stdout
are not set or are not strings.

(cherry picked from commit c2cf128)
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Mar 16, 2017
if attributes "encoding" or "errors" of sys.stdin or sys.stdout
are not set or are not strings.

(cherry picked from commit c2cf128)
@serhiy-storchaka serhiy-storchaka deleted the bpo-8256-input-fallback branch March 30, 2017 18:54
jaraco pushed a commit that referenced this pull request Dec 2, 2022
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants