Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(11)

Side by Side Diff: Python/bltinmodule.c

Issue 8256: input() doesn't catch _PyUnicode_AsString() exception; io.StringIO().encoding is None
Patch Set: Created 7 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_builtin.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Built-in functions */ 1 /* Built-in functions */
2 2
3 #include "Python.h" 3 #include "Python.h"
4 #include "Python-ast.h" 4 #include "Python-ast.h"
5 5
6 #include "node.h" 6 #include "node.h"
7 #include "code.h" 7 #include "code.h"
8 8
9 #include "asdl.h" 9 #include "asdl.h"
10 #include "ast.h" 10 #include "ast.h"
(...skipping 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after
1702 if (promptarg != NULL) { 1702 if (promptarg != NULL) {
1703 /* We have a prompt, encode it as stdout would */ 1703 /* We have a prompt, encode it as stdout would */
1704 char *stdout_encoding_str, *stdout_errors_str; 1704 char *stdout_encoding_str, *stdout_errors_str;
1705 PyObject *stringpo; 1705 PyObject *stringpo;
1706 stdout_encoding = _PyObject_GetAttrId(fout, &PyId_encoding); 1706 stdout_encoding = _PyObject_GetAttrId(fout, &PyId_encoding);
1707 stdout_errors = _PyObject_GetAttrId(fout, &PyId_errors); 1707 stdout_errors = _PyObject_GetAttrId(fout, &PyId_errors);
1708 if (!stdout_encoding || !stdout_errors) 1708 if (!stdout_encoding || !stdout_errors)
1709 goto _readline_errors; 1709 goto _readline_errors;
1710 stdout_encoding_str = _PyUnicode_AsString(stdout_encoding); 1710 stdout_encoding_str = _PyUnicode_AsString(stdout_encoding);
1711 stdout_errors_str = _PyUnicode_AsString(stdout_errors); 1711 stdout_errors_str = _PyUnicode_AsString(stdout_errors);
1712 if (!stdout_encoding_str || !stdout_errors_str) 1712 if (!stdout_encoding_str || !stdout_errors_str) {
1713 goto _readline_errors; 1713 /* invalid encoding or errors attributes on stdin,
1714 check stderr for valid values */
1715 PyErr_Clear();
1716 stdout_encoding = _PyObject_GetAttrId(ferr, &PyId_encoding);
1717 stdout_errors = _PyObject_GetAttrId(ferr, &PyId_errors);
1718 if (!stdout_encoding || !stdout_errors)
1719 goto _readline_errors;
1720 stdout_encoding_str = _PyUnicode_AsString(stdout_encoding);
1721 stdout_errors_str = _PyUnicode_AsString(stdout_errors);
1722 if (!stdout_encoding_str || !stdout_errors_str)
1723 goto _readline_errors;
1724 }
1714 stringpo = PyObject_Str(promptarg); 1725 stringpo = PyObject_Str(promptarg);
1715 if (stringpo == NULL) 1726 if (stringpo == NULL)
1716 goto _readline_errors; 1727 goto _readline_errors;
1717 po = PyUnicode_AsEncodedString(stringpo, 1728 po = PyUnicode_AsEncodedString(stringpo,
1718 stdout_encoding_str, stdout_errors_str); 1729 stdout_encoding_str, stdout_errors_str);
1719 Py_CLEAR(stdout_encoding); 1730 Py_CLEAR(stdout_encoding);
1720 Py_CLEAR(stdout_errors); 1731 Py_CLEAR(stdout_errors);
1721 Py_CLEAR(stringpo); 1732 Py_CLEAR(stringpo);
1722 if (po == NULL) 1733 if (po == NULL)
1723 goto _readline_errors; 1734 goto _readline_errors;
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
2462 if (PyDict_SetItemString(dict, "__debug__", debug) < 0) { 2473 if (PyDict_SetItemString(dict, "__debug__", debug) < 0) {
2463 Py_XDECREF(debug); 2474 Py_XDECREF(debug);
2464 return NULL; 2475 return NULL;
2465 } 2476 }
2466 Py_XDECREF(debug); 2477 Py_XDECREF(debug);
2467 2478
2468 return mod; 2479 return mod;
2469 #undef ADD_TO_ALL 2480 #undef ADD_TO_ALL
2470 #undef SETBUILTIN 2481 #undef SETBUILTIN
2471 } 2482 }
OLDNEW
« no previous file with comments | « Lib/test/test_builtin.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+