Skip to content
Permalink
Browse files

Add a py2/py3 check and use the appropriate argument for writing to b…

…inary files
  • Loading branch information...
geographika committed Oct 11, 2018
1 parent e7fc3ca commit 9622306c9d9a149dbbd6a0786a194fc6a5a5e097
Showing with 6 additions and 4 deletions.
  1. +6 −4 mapscript/python/pyextend.i
@@ -187,12 +187,14 @@ def fromstring(data, mappath=None):
msSetError(MS_IMGERR, "failed to get image buffer", "write()");
return MS_FAILURE;
}
#if PY_MAJOR_VERSION >= 3
// see https://docs.python.org/3/c-api/arg.html

%#if PY_MAJOR_VERSION >= 3
// https://docs.python.org/3/c-api/arg.html
noerr = PyObject_CallMethod(file, "write", "y#", imgbuffer, imgsize);
#else
%#else
// https://docs.python.org/2/c-api/arg.html
noerr = PyObject_CallMethod(file, "write", "s#", imgbuffer, imgsize);
#endif
%#endif

free(imgbuffer);
if (noerr == NULL)

0 comments on commit 9622306

Please sign in to comment.
You can’t perform that action at this time.