Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4dbd02c
bpo-29532: Altering a kwarg dictionary passed to functools.partial() …
serhiy-storchaka Feb 20, 2017
63de4ae
Merge branch '3.6' of https://github.com/python/cpython into 3.6
serhiy-storchaka Feb 21, 2017
8d0b396
Merge branch '3.6' of https://github.com/python/cpython into 3.6
serhiy-storchaka Feb 21, 2017
227d289
Merge branch '3.6' of https://github.com/python/cpython into 3.6
serhiy-storchaka Feb 24, 2017
56fc6a3
Merge branch '3.6' of https://github.com/python/cpython into 3.6
serhiy-storchaka Feb 28, 2017
a1253ef
Merge remote-tracking branch 'upstream/3.6' into 3.6
serhiy-storchaka Mar 1, 2017
b785efc
Merge branch '3.6' of https://github.com/python/cpython into 3.6
serhiy-storchaka Mar 2, 2017
ca8b6f7
Merge branch '3.6' of https://github.com/python/cpython into 3.6
serhiy-storchaka Mar 3, 2017
4b6e44d
Merge remote-tracking branch 'upstream/3.6' into 3.6
serhiy-storchaka Mar 4, 2017
fffab40
Merge remote-tracking branch 'upstream/3.6' into 3.6
serhiy-storchaka Mar 5, 2017
6073a16
Merge remote-tracking branch 'upstream/3.6' into 3.6
serhiy-storchaka Mar 5, 2017
d80cc35
Merge remote-tracking branch 'upstream/3.6' into 3.6
serhiy-storchaka Mar 6, 2017
90c56c7
Merge remote-tracking branch 'upstream/3.6' into 3.6
serhiy-storchaka Mar 8, 2017
d81e614
bpo-28230: Document the pathlib support in tarfile and add tests. (#512)
serhiy-storchaka Mar 8, 2017
adc0a8a
Merge remote-tracking branch 'upstream/3.6' into 3.6
serhiy-storchaka Mar 8, 2017
157d3d9
bpo-28231: The zipfile module now accepts path-like objects for exter…
serhiy-storchaka Mar 8, 2017
db1982f
Update NEWS
serhiy-storchaka Mar 8, 2017
a0ad1a6
Merge remote-tracking branch 'upstream/3.6' into 3.6
serhiy-storchaka Mar 9, 2017
c3d232b
bpo-29768: Fixed compile-time check for expat version. (#574)
serhiy-storchaka Mar 9, 2017
b30c7a5
bpo-29773: Add more cases for testing string to float conversion erro…
serhiy-storchaka Mar 9, 2017
8fa0399
Merge remote-tracking branch 'upstream/3.6' into 3.6
serhiy-storchaka Mar 9, 2017
63d0b90
Merge remote-tracking branch 'upstream/3.6' into 3.6
serhiy-storchaka Mar 12, 2017
7763679
bpo-8256: Fixed possible failing or crashing input() (#517)
serhiy-storchaka Mar 12, 2017
e9bef40
bpo-8256: Fixed possible failing or crashing input() if attributes "e…
serhiy-storchaka Mar 12, 2017
9cf5390
Merge branch '3.6' of github.com:serhiy-storchaka/cpython into 3.6
serhiy-storchaka Mar 12, 2017
1f06786
Remove bad cherry-picked entries from Misc/NEWS.
serhiy-storchaka Mar 12, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Core and Builtins
Library
-------

- bpo-8256: Fixed possible failing or crashing input() if attributes "encoding"
or "errors" of sys.stdin or sys.stdout are not set or are not strings.

- bpo-28298: Fix a bug that prevented array 'Q', 'L' and 'I' from accepting big
intables (objects that have __int__) as elements. Patch by Oren Milman.

Expand Down
21 changes: 16 additions & 5 deletions Python/bltinmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1927,12 +1927,15 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
PyObject *result;
size_t len;

/* stdin is a text stream, so it must have an encoding. */
stdin_encoding = _PyObject_GetAttrId(fin, &PyId_encoding);
stdin_errors = _PyObject_GetAttrId(fin, &PyId_errors);
if (!stdin_encoding || !stdin_errors)
/* stdin is a text stream, so it must have an
encoding. */
if (!stdin_encoding || !stdin_errors ||
!PyUnicode_Check(stdin_encoding) ||
!PyUnicode_Check(stdin_errors)) {
tty = 0;
goto _readline_errors;
}
stdin_encoding_str = PyUnicode_AsUTF8(stdin_encoding);
stdin_errors_str = PyUnicode_AsUTF8(stdin_errors);
if (!stdin_encoding_str || !stdin_errors_str)
Expand All @@ -1948,8 +1951,12 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
PyObject *stringpo;
stdout_encoding = _PyObject_GetAttrId(fout, &PyId_encoding);
stdout_errors = _PyObject_GetAttrId(fout, &PyId_errors);
if (!stdout_encoding || !stdout_errors)
if (!stdout_encoding || !stdout_errors ||
!PyUnicode_Check(stdout_encoding) ||
!PyUnicode_Check(stdout_errors)) {
tty = 0;
goto _readline_errors;
}
stdout_encoding_str = PyUnicode_AsUTF8(stdout_encoding);
stdout_errors_str = PyUnicode_AsUTF8(stdout_errors);
if (!stdout_encoding_str || !stdout_errors_str)
Expand Down Expand Up @@ -2003,13 +2010,17 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
Py_XDECREF(po);
PyMem_FREE(s);
return result;

_readline_errors:
Py_XDECREF(stdin_encoding);
Py_XDECREF(stdout_encoding);
Py_XDECREF(stdin_errors);
Py_XDECREF(stdout_errors);
Py_XDECREF(po);
return NULL;
if (tty)
return NULL;

PyErr_Clear();
}

/* Fallback if we're not interactive */
Expand Down