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.
This commit is contained in:
Brian Crowell 2012-10-20 16:27:45 -05:00 committed by Brian Crowell
parent 275a895952
commit 8b704e3005
2 changed files with 8 additions and 10 deletions

View File

@ -501,9 +501,8 @@ cms_get_display_profile_win32(PyObject* self, PyObject* args)
static PyMethodDef pyCMSdll_methods[] = { static PyMethodDef pyCMSdll_methods[] = {
{"profile_open", cms_profile_open, 1}, {"profile_open", cms_profile_open, 1},
#if PY_VERSION_HEX >= 0x03000000
{"profile_frombytes", cms_profile_fromstring, 1}, {"profile_frombytes", cms_profile_fromstring, 1},
#else #if PY_VERSION_HEX < 0x03000000
{"profile_fromstring", cms_profile_fromstring, 1}, {"profile_fromstring", cms_profile_fromstring, 1},
#endif #endif

View File

@ -180,7 +180,7 @@ _releasedc(ImagingDisplayObject* display, PyObject* args)
} }
static PyObject* static PyObject*
_fromstring(ImagingDisplayObject* display, PyObject* args) _frombytes(ImagingDisplayObject* display, PyObject* args)
{ {
char* ptr; char* ptr;
int bytes; int bytes;
@ -205,7 +205,7 @@ _fromstring(ImagingDisplayObject* display, PyObject* args)
} }
static PyObject* static PyObject*
_tostring(ImagingDisplayObject* display, PyObject* args) _tobytes(ImagingDisplayObject* display, PyObject* args)
{ {
#if PY_VERSION_HEX >= 0x03000000 #if PY_VERSION_HEX >= 0x03000000
if (!PyArg_ParseTuple(args, ":tobytes")) if (!PyArg_ParseTuple(args, ":tobytes"))
@ -227,12 +227,11 @@ static struct PyMethodDef methods[] = {
{"query_palette", (PyCFunction)_query_palette, 1}, {"query_palette", (PyCFunction)_query_palette, 1},
{"getdc", (PyCFunction)_getdc, 1}, {"getdc", (PyCFunction)_getdc, 1},
{"releasedc", (PyCFunction)_releasedc, 1}, {"releasedc", (PyCFunction)_releasedc, 1},
#if PY_VERSION_HEX >= 0x03000000 {"frombytes", (PyCFunction)_frombytes, 1},
{"frombytes", (PyCFunction)_fromstring, 1}, {"tobytes", (PyCFunction)_tobytes, 1},
{"tobytes", (PyCFunction)_tostring, 1}, #if PY_VERSION_HEX < 0x03000000
#else {"fromstring", (PyCFunction)_frombytes, 1},
{"fromstring", (PyCFunction)_fromstring, 1}, {"tostring", (PyCFunction)_tobytes, 1},
{"tostring", (PyCFunction)_tostring, 1},
#endif #endif
{NULL, NULL} /* sentinel */ {NULL, NULL} /* sentinel */
}; };