diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-12-09 19:49:49 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-12-09 19:49:49 (GMT) |
commit | e3b47152a481313081621b46381384d18d0419e8 (patch) | |
tree | fe32c783377a494715e0b1ebf188548f9bc09adc /Modules | |
parent | db6238964d534a160f2b2d8b2b61e19a3d3dee47 (diff) | |
download | cpython-e3b47152a481313081621b46381384d18d0419e8.zip cpython-e3b47152a481313081621b46381384d18d0419e8.tar.gz cpython-e3b47152a481313081621b46381384d18d0419e8.tar.bz2 |
Write tests for invalid characters (U+00110000)
Test the following functions:
* codecs.raw_unicode_escape_decode()
* PyUnicode_FromWideChar()
* PyUnicode_FromUnicode()
* "unicode_internal" and "unicode_escape" decoders
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_testcapimodule.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 962f10b..a9bb5be 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -1409,6 +1409,7 @@ test_widechar(PyObject *self) #if defined(SIZEOF_WCHAR_T) && (SIZEOF_WCHAR_T == 4) const wchar_t wtext[2] = {(wchar_t)0x10ABCDu}; size_t wtextlen = 1; + const wchar_t invalid[1] = {(wchar_t)0x110000u}; #else const wchar_t wtext[3] = {(wchar_t)0xDBEAu, (wchar_t)0xDFCDu}; size_t wtextlen = 2; @@ -1444,6 +1445,23 @@ test_widechar(PyObject *self) Py_DECREF(wide); Py_DECREF(utf8); + +#if defined(SIZEOF_WCHAR_T) && (SIZEOF_WCHAR_T == 4) + wide = PyUnicode_FromWideChar(invalid, 1); + if (wide == NULL) + PyErr_Clear(); + else + return raiseTestError("test_widechar", + "PyUnicode_FromWideChar(L\"\\U00110000\", 1) didn't fail"); + + wide = PyUnicode_FromUnicode(invalid, 1); + if (wide == NULL) + PyErr_Clear(); + else + return raiseTestError("test_widechar", + "PyUnicode_FromUnicode(L\"\\U00110000\", 1) didn't fail"); +#endif + Py_RETURN_NONE; } |