Issue #28526: Use PyUnicode_AsEncodedString() instead of

PyUnicode_AsEncodedObject() in _curese to ensure that the result
is a bytes object.
This commit is contained in:
Serhiy Storchaka 2016-10-27 19:31:49 +03:00
parent bb444772d9
commit b29cee40ee
1 changed files with 2 additions and 2 deletions

View File

@ -230,7 +230,7 @@ PyCurses_ConvertToChtype(PyCursesWindowObject *win, PyObject *obj, chtype *ch)
encoding = win->encoding; encoding = win->encoding;
else else
encoding = screen_encoding; encoding = screen_encoding;
bytes = PyUnicode_AsEncodedObject(obj, encoding, NULL); bytes = PyUnicode_AsEncodedString(obj, encoding, NULL);
if (bytes == NULL) if (bytes == NULL)
return 0; return 0;
if (PyBytes_GET_SIZE(bytes) == 1) if (PyBytes_GET_SIZE(bytes) == 1)
@ -352,7 +352,7 @@ PyCurses_ConvertToString(PyCursesWindowObject *win, PyObject *obj,
return 2; return 2;
#else #else
assert (wstr == NULL); assert (wstr == NULL);
*bytes = PyUnicode_AsEncodedObject(obj, win->encoding, NULL); *bytes = PyUnicode_AsEncodedString(obj, win->encoding, NULL);
if (*bytes == NULL) if (*bytes == NULL)
return 0; return 0;
return 1; return 1;