Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert #3780 for PyPy3 as it hasn't been updated yet. #3935

Merged
merged 2 commits into from Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions Tests/test_imagefont.py
Expand Up @@ -465,8 +465,9 @@ def test_unicode_pilfont(self):
font.getsize(u"’")

@unittest.skipIf(
sys.platform.startswith("win32") and sys.version.startswith("2"),
"requires Python 3.x on Windows",
sys.platform.startswith("win32")
and (sys.version.startswith("2") or hasattr(sys, "pypy_translation_info")),
"requires CPython 3.x on Windows",
)
def test_unicode_extended(self):
# issue #3777
Expand Down
13 changes: 8 additions & 5 deletions src/_imagingft.c
Expand Up @@ -327,7 +327,7 @@ getfont(PyObject* self_, PyObject* args, PyObject* kw)
static int
font_getchar(PyObject* string, int index, FT_ULong* char_out)
{
#if PY_VERSION_HEX < 0x03000000
#if (PY_VERSION_HEX < 0x03030000) || (defined(PYPY_VERSION_NUM))
if (PyUnicode_Check(string)) {
Py_UNICODE* p = PyUnicode_AS_UNICODE(string);
int size = PyUnicode_GET_SIZE(string);
Expand All @@ -336,7 +336,7 @@ font_getchar(PyObject* string, int index, FT_ULong* char_out)
*char_out = p[index];
return 1;
}

#if PY_VERSION_HEX < 0x03000000
if (PyString_Check(string)) {
unsigned char* p = (unsigned char*) PyString_AS_STRING(string);
int size = PyString_GET_SIZE(string);
Expand All @@ -345,6 +345,7 @@ font_getchar(PyObject* string, int index, FT_ULong* char_out)
*char_out = (unsigned char) p[index];
return 1;
}
#endif
#else
if (PyUnicode_Check(string)) {
if (index >= PyUnicode_GET_LENGTH(string))
Expand Down Expand Up @@ -373,7 +374,7 @@ text_layout_raqm(PyObject* string, FontObject* self, const char* dir, PyObject *
goto failed;
}

#if PY_VERSION_HEX < 0x03000000
#if (PY_VERSION_HEX < 0x03030000) || (defined(PYPY_VERSION_NUM))
if (PyUnicode_Check(string)) {
Py_UNICODE *text = PyUnicode_AS_UNICODE(string);
Py_ssize_t size = PyUnicode_GET_SIZE(string);
Expand All @@ -392,8 +393,9 @@ text_layout_raqm(PyObject* string, FontObject* self, const char* dir, PyObject *
goto failed;
}
}

} else if (PyString_Check(string)) {
}
#if PY_VERSION_HEX < 0x03000000
else if (PyString_Check(string)) {
char *text = PyString_AS_STRING(string);
int size = PyString_GET_SIZE(string);
if (! size) {
Expand All @@ -410,6 +412,7 @@ text_layout_raqm(PyObject* string, FontObject* self, const char* dir, PyObject *
}
}
}
#endif
#else
if (PyUnicode_Check(string)) {
Py_UCS4 *text = PyUnicode_AsUCS4Copy(string);
Expand Down