Skip to content

Commit aaca672

Browse files
authored
Revert #3780 for PyPy3 as it hasn't been updated yet. (#3935)
Revert #3780 for PyPy3 as it hasn't been updated yet.
2 parents eedac36 + 14ddfd3 commit aaca672

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

Tests/test_imagefont.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,9 @@ def test_unicode_pilfont(self):
465465
font.getsize(u"’")
466466

467467
@unittest.skipIf(
468-
sys.platform.startswith("win32") and sys.version.startswith("2"),
469-
"requires Python 3.x on Windows",
468+
sys.platform.startswith("win32")
469+
and (sys.version.startswith("2") or hasattr(sys, "pypy_translation_info")),
470+
"requires CPython 3.x on Windows",
470471
)
471472
def test_unicode_extended(self):
472473
# issue #3777

src/_imagingft.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ getfont(PyObject* self_, PyObject* args, PyObject* kw)
327327
static int
328328
font_getchar(PyObject* string, int index, FT_ULong* char_out)
329329
{
330-
#if PY_VERSION_HEX < 0x03000000
330+
#if (PY_VERSION_HEX < 0x03030000) || (defined(PYPY_VERSION_NUM))
331331
if (PyUnicode_Check(string)) {
332332
Py_UNICODE* p = PyUnicode_AS_UNICODE(string);
333333
int size = PyUnicode_GET_SIZE(string);
@@ -336,7 +336,7 @@ font_getchar(PyObject* string, int index, FT_ULong* char_out)
336336
*char_out = p[index];
337337
return 1;
338338
}
339-
339+
#if PY_VERSION_HEX < 0x03000000
340340
if (PyString_Check(string)) {
341341
unsigned char* p = (unsigned char*) PyString_AS_STRING(string);
342342
int size = PyString_GET_SIZE(string);
@@ -345,6 +345,7 @@ font_getchar(PyObject* string, int index, FT_ULong* char_out)
345345
*char_out = (unsigned char) p[index];
346346
return 1;
347347
}
348+
#endif
348349
#else
349350
if (PyUnicode_Check(string)) {
350351
if (index >= PyUnicode_GET_LENGTH(string))
@@ -373,7 +374,7 @@ text_layout_raqm(PyObject* string, FontObject* self, const char* dir, PyObject *
373374
goto failed;
374375
}
375376

376-
#if PY_VERSION_HEX < 0x03000000
377+
#if (PY_VERSION_HEX < 0x03030000) || (defined(PYPY_VERSION_NUM))
377378
if (PyUnicode_Check(string)) {
378379
Py_UNICODE *text = PyUnicode_AS_UNICODE(string);
379380
Py_ssize_t size = PyUnicode_GET_SIZE(string);
@@ -392,8 +393,9 @@ text_layout_raqm(PyObject* string, FontObject* self, const char* dir, PyObject *
392393
goto failed;
393394
}
394395
}
395-
396-
} else if (PyString_Check(string)) {
396+
}
397+
#if PY_VERSION_HEX < 0x03000000
398+
else if (PyString_Check(string)) {
397399
char *text = PyString_AS_STRING(string);
398400
int size = PyString_GET_SIZE(string);
399401
if (! size) {
@@ -410,6 +412,7 @@ text_layout_raqm(PyObject* string, FontObject* self, const char* dir, PyObject *
410412
}
411413
}
412414
}
415+
#endif
413416
#else
414417
if (PyUnicode_Check(string)) {
415418
Py_UCS4 *text = PyUnicode_AsUCS4Copy(string);

0 commit comments

Comments
 (0)