mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-10 00:20:57 +03:00
Merge pull request #4145 from nulano/ucs4-pypy
Fix Unicode support for PyPy
This commit is contained in:
commit
37be3b0dda
4
.github/workflows/test-windows.yml
vendored
4
.github/workflows/test-windows.yml
vendored
|
@ -253,7 +253,6 @@ jobs:
|
||||||
|
|
||||||
# for Raqm
|
# for Raqm
|
||||||
- name: Build dependencies / HarfBuzz
|
- name: Build dependencies / HarfBuzz
|
||||||
if: "!contains(matrix.python-version, 'pypy')"
|
|
||||||
run: |
|
run: |
|
||||||
set INCLUDE=C:\Program Files (x86)\Microsoft SDKs\Windows\V7.1A\Include
|
set INCLUDE=C:\Program Files (x86)\Microsoft SDKs\Windows\V7.1A\Include
|
||||||
set INCLIB=%GITHUB_WORKSPACE%\winbuild\depends\msvcr10-x32
|
set INCLIB=%GITHUB_WORKSPACE%\winbuild\depends\msvcr10-x32
|
||||||
|
@ -274,7 +273,6 @@ jobs:
|
||||||
|
|
||||||
# for Raqm
|
# for Raqm
|
||||||
- name: Build dependencies / FriBidi
|
- name: Build dependencies / FriBidi
|
||||||
if: "!contains(matrix.python-version, 'pypy')"
|
|
||||||
run: |
|
run: |
|
||||||
set INCLUDE=C:\Program Files (x86)\Microsoft SDKs\Windows\V7.1A\Include
|
set INCLUDE=C:\Program Files (x86)\Microsoft SDKs\Windows\V7.1A\Include
|
||||||
set INCLIB=%GITHUB_WORKSPACE%\winbuild\depends\msvcr10-x32
|
set INCLIB=%GITHUB_WORKSPACE%\winbuild\depends\msvcr10-x32
|
||||||
|
@ -292,9 +290,7 @@ jobs:
|
||||||
copy /Y /B *.lib %INCLIB%
|
copy /Y /B *.lib %INCLIB%
|
||||||
shell: cmd
|
shell: cmd
|
||||||
|
|
||||||
# failing with PyPy3
|
|
||||||
- name: Build dependencies / Raqm
|
- name: Build dependencies / Raqm
|
||||||
if: "!contains(matrix.python-version, 'pypy')"
|
|
||||||
run: |
|
run: |
|
||||||
set INCLUDE=C:\Program Files (x86)\Microsoft SDKs\Windows\V7.1A\Include
|
set INCLUDE=C:\Program Files (x86)\Microsoft SDKs\Windows\V7.1A\Include
|
||||||
set INCLIB=%GITHUB_WORKSPACE%\winbuild\depends\msvcr10-x32
|
set INCLIB=%GITHUB_WORKSPACE%\winbuild\depends\msvcr10-x32
|
||||||
|
|
|
@ -464,7 +464,7 @@ class TestImageFont(PillowTestCase):
|
||||||
with self.assertRaises(UnicodeEncodeError):
|
with self.assertRaises(UnicodeEncodeError):
|
||||||
font.getsize("’")
|
font.getsize("’")
|
||||||
|
|
||||||
@unittest.skipIf(is_pypy(), "requires CPython")
|
@unittest.skipIf(is_pypy(), "failing on PyPy")
|
||||||
def test_unicode_extended(self):
|
def test_unicode_extended(self):
|
||||||
# issue #3777
|
# issue #3777
|
||||||
text = "A\u278A\U0001F12B"
|
text = "A\u278A\U0001F12B"
|
||||||
|
|
|
@ -326,24 +326,12 @@ getfont(PyObject* self_, PyObject* args, PyObject* kw)
|
||||||
static int
|
static int
|
||||||
font_getchar(PyObject* string, int index, FT_ULong* char_out)
|
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 (PyUnicode_Check(string)) {
|
||||||
if (index >= PyUnicode_GET_LENGTH(string))
|
if (index >= PyUnicode_GET_LENGTH(string))
|
||||||
return 0;
|
return 0;
|
||||||
*char_out = PyUnicode_READ_CHAR(string, index);
|
*char_out = PyUnicode_READ_CHAR(string, index);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,7 +351,7 @@ text_layout_raqm(PyObject* string, FontObject* self, const char* dir, PyObject *
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (defined(PYPY_VERSION_NUM))
|
#if (defined(PYPY_VERSION_NUM) && (PYPY_VERSION_NUM < 0x07020000))
|
||||||
if (PyUnicode_Check(string)) {
|
if (PyUnicode_Check(string)) {
|
||||||
Py_UNICODE *text = PyUnicode_AS_UNICODE(string);
|
Py_UNICODE *text = PyUnicode_AS_UNICODE(string);
|
||||||
Py_ssize_t size = PyUnicode_GET_SIZE(string);
|
Py_ssize_t size = PyUnicode_GET_SIZE(string);
|
||||||
|
@ -392,7 +380,7 @@ text_layout_raqm(PyObject* string, FontObject* self, const char* dir, PyObject *
|
||||||
and raqm fails with empty strings */
|
and raqm fails with empty strings */
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
int set_text = (*p_raqm.set_text)(rq, (const uint32_t *)(text), size);
|
int set_text = (*p_raqm.set_text)(rq, text, size);
|
||||||
PyMem_Free(text);
|
PyMem_Free(text);
|
||||||
if (!set_text) {
|
if (!set_text) {
|
||||||
PyErr_SetString(PyExc_ValueError, "raqm_set_text() failed");
|
PyErr_SetString(PyExc_ValueError, "raqm_set_text() failed");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user