summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-01-26 15:41:32 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-01-26 15:41:32 (GMT)
commit29dacf2e97314a16db3f2bef492d1c46f39ad656 (patch)
treeeee087480c15254bac655e9768dff58d0e2201ec /Objects
parenta8efc9601da1fb1402253124767edbb1b1270a8b (diff)
downloadcpython-29dacf2e97314a16db3f2bef492d1c46f39ad656.zip
cpython-29dacf2e97314a16db3f2bef492d1c46f39ad656.tar.gz
cpython-29dacf2e97314a16db3f2bef492d1c46f39ad656.tar.bz2
Issue #15859: PyUnicode_EncodeFSDefault(), PyUnicode_EncodeMBCS() and
PyUnicode_EncodeCodePage() now raise an exception if the object is not an Unicode object. For PyUnicode_EncodeFSDefault(), it was already the case on platforms other than Windows. Patch written by Campbell Barton.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 03f795c..101bfbc 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -7431,6 +7431,11 @@ encode_code_page(int code_page,
Py_ssize_t offset;
int chunk_len, ret, done;
+ if (!PyUnicode_Check(unicode)) {
+ PyErr_BadArgument();
+ return NULL;
+ }
+
if (PyUnicode_READY(unicode) == -1)
return NULL;
len = PyUnicode_GET_LENGTH(unicode);
@@ -7504,10 +7509,6 @@ PyUnicode_EncodeCodePage(int code_page,
PyObject *
PyUnicode_AsMBCSString(PyObject *unicode)
{
- if (!PyUnicode_Check(unicode)) {
- PyErr_BadArgument();
- return NULL;
- }
return PyUnicode_EncodeCodePage(CP_ACP, unicode, NULL);
}