From 8b704e3005e3b7e7089ffee1c17c7117b293807a Mon Sep 17 00:00:00 2001 From: Brian Crowell Date: Sat, 20 Oct 2012 16:27:45 -0500 Subject: [PATCH] py3k: Publish both frombytes and fromstring in C modules for old Python To ease the transition, frombytes and tobytes need to be declared in both versions. --- _imagingcms.c | 3 +-- display.c | 15 +++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/_imagingcms.c b/_imagingcms.c index 910dc6eeb..65958f33a 100644 --- a/_imagingcms.c +++ b/_imagingcms.c @@ -501,9 +501,8 @@ cms_get_display_profile_win32(PyObject* self, PyObject* args) static PyMethodDef pyCMSdll_methods[] = { {"profile_open", cms_profile_open, 1}, -#if PY_VERSION_HEX >= 0x03000000 {"profile_frombytes", cms_profile_fromstring, 1}, -#else +#if PY_VERSION_HEX < 0x03000000 {"profile_fromstring", cms_profile_fromstring, 1}, #endif diff --git a/display.c b/display.c index 9571b1cbe..1ce537c64 100644 --- a/display.c +++ b/display.c @@ -180,7 +180,7 @@ _releasedc(ImagingDisplayObject* display, PyObject* args) } static PyObject* -_fromstring(ImagingDisplayObject* display, PyObject* args) +_frombytes(ImagingDisplayObject* display, PyObject* args) { char* ptr; int bytes; @@ -205,7 +205,7 @@ _fromstring(ImagingDisplayObject* display, PyObject* args) } static PyObject* -_tostring(ImagingDisplayObject* display, PyObject* args) +_tobytes(ImagingDisplayObject* display, PyObject* args) { #if PY_VERSION_HEX >= 0x03000000 if (!PyArg_ParseTuple(args, ":tobytes")) @@ -227,12 +227,11 @@ static struct PyMethodDef methods[] = { {"query_palette", (PyCFunction)_query_palette, 1}, {"getdc", (PyCFunction)_getdc, 1}, {"releasedc", (PyCFunction)_releasedc, 1}, -#if PY_VERSION_HEX >= 0x03000000 - {"frombytes", (PyCFunction)_fromstring, 1}, - {"tobytes", (PyCFunction)_tostring, 1}, -#else - {"fromstring", (PyCFunction)_fromstring, 1}, - {"tostring", (PyCFunction)_tostring, 1}, + {"frombytes", (PyCFunction)_frombytes, 1}, + {"tobytes", (PyCFunction)_tobytes, 1}, +#if PY_VERSION_HEX < 0x03000000 + {"fromstring", (PyCFunction)_frombytes, 1}, + {"tostring", (PyCFunction)_tobytes, 1}, #endif {NULL, NULL} /* sentinel */ };