From 837d8ae984e5959633483191376b70d652e89379 Mon Sep 17 00:00:00 2001 From: nulano Date: Sun, 13 Oct 2019 00:11:48 +0100 Subject: [PATCH] fix support for extended unicode characters in PyPy --- Tests/test_imagefont.py | 2 +- src/_imagingft.c | 14 +------------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/Tests/test_imagefont.py b/Tests/test_imagefont.py index b7cfefacf..1c44e5221 100644 --- a/Tests/test_imagefont.py +++ b/Tests/test_imagefont.py @@ -463,7 +463,7 @@ class TestImageFont(PillowTestCase): with self.assertRaises(UnicodeEncodeError): font.getsize("’") - @unittest.skipIf(is_pypy(), "requires CPython") + @unittest.skipIf(is_pypy(), "failing on PyPy") def test_unicode_extended(self): # issue #3777 text = "A\u278A\U0001F12B" diff --git a/src/_imagingft.c b/src/_imagingft.c index 0a9c00a91..d89f9a758 100644 --- a/src/_imagingft.c +++ b/src/_imagingft.c @@ -326,24 +326,12 @@ getfont(PyObject* self_, PyObject* args, PyObject* kw) static int font_getchar(PyObject* string, int index, FT_ULong* char_out) { -#if (defined(PYPY_VERSION_NUM)) - if (PyUnicode_Check(string)) { - Py_UNICODE* p = PyUnicode_AS_UNICODE(string); - int size = PyUnicode_GET_SIZE(string); - if (index >= size) - return 0; - *char_out = p[index]; - return 1; - } -#else if (PyUnicode_Check(string)) { if (index >= PyUnicode_GET_LENGTH(string)) return 0; *char_out = PyUnicode_READ_CHAR(string, index); return 1; } -#endif - return 0; } @@ -363,7 +351,7 @@ text_layout_raqm(PyObject* string, FontObject* self, const char* dir, PyObject * goto failed; } -#if (defined(PYPY_VERSION_NUM)) +#if (defined(PYPY_VERSION_NUM) && (PYPY_VERSION_NUM < 0x07020000)) if (PyUnicode_Check(string)) { Py_UNICODE *text = PyUnicode_AS_UNICODE(string); Py_ssize_t size = PyUnicode_GET_SIZE(string);