summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2012-12-09 13:22:19 +0100
committerStefan Behnel <stefan_ml@behnel.de>2012-12-09 13:22:19 +0100
commit109ab9a8f342feea87113cd268e082fbdf1da53f (patch)
tree5b78890d2d0c0682116e4c9bd723a0146c2f5e44
parent3b67ea4ba509e9554969417d1d4c743c0c8fa974 (diff)
downloadcython-109ab9a8f342feea87113cd268e082fbdf1da53f.tar.gz
raise overflow error in Py3.3+ when non-BMP Unicode characters are coerced into a short Py_UNICODE value
--HG-- extra : transplant_source : %D3%96%7C%F9%3F%AE%1AA%8C%B9%0E%918%FB%27%F4%CB%E7u-
-rw-r--r--CHANGES.rst4
-rw-r--r--Cython/Utility/TypeConversion.c4
2 files changed, 8 insertions, 0 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index 246ebb96c..2d6652855 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -188,6 +188,10 @@ Features added
Bugs fixed
----------
+* In CPython 3.3, converting a Unicode character to the Py_UNICODE type
+ could fail to raise an overflow for non-BMP characters that do not fit
+ into a wchar_t on the current platform.
+
Other changes
-------------
diff --git a/Cython/Utility/TypeConversion.c b/Cython/Utility/TypeConversion.c
index c2bb6f11f..e551f990d 100644
--- a/Cython/Utility/TypeConversion.c
+++ b/Cython/Utility/TypeConversion.c
@@ -94,8 +94,12 @@ static CYTHON_INLINE Py_UNICODE __Pyx_PyObject_AsPy_UNICODE(PyObject*);
static CYTHON_INLINE Py_UNICODE __Pyx_PyObject_AsPy_UNICODE(PyObject* x) {
long ival;
#if CYTHON_PEP393_ENABLED
+ #if Py_UNICODE_SIZE > 2
const long maxval = 1114111;
#else
+ const long maxval = 65535;
+ #endif
+ #else
static long maxval = 0;
#endif
if (PyUnicode_Check(x)) {