Mercurial > pygame
diff src/bufferproxy.c @ 3088:fb1a30254d10
Apply issue #109 suggested bug fixes.
Use the submitted patches as a guide to making x86_64 compatibility fixes.
I decided to make font_index the correct type, long, rather than just
correct the format string. For bufferproxy, use conditional compilation
to choose the correct format string based on Python version.
Thanks lifning and cgohlke.
| author | Lenard Lindstrom <len-l@telus.net> |
|---|---|
| date | Sun, 11 Mar 2012 20:20:47 -0700 |
| parents | 42e2bde1a12c |
| children |
line wrap: on
line diff
--- a/src/bufferproxy.c Sun Mar 11 20:06:23 2012 -0700 +++ b/src/bufferproxy.c Sun Mar 11 20:20:47 2012 -0700 @@ -20,6 +20,7 @@ #define PYGAMEAPI_BUFFERPROXY_INTERNAL +#define PY_SSIZE_T_CLEAN #define NO_PYGAME_C_API #include "pygame.h" #include "pgcompat.h" @@ -255,7 +256,13 @@ Py_ssize_t length; char *buf; - if (!PyArg_ParseTuple (args, "s#i", &buf, &length, &offset)) +#if PY_VERSION_HEX < 0x02050000 +#define FORMAT_STRING "s#i" +#else +#define FORMAT_STRING "s#n" +#endif + + if (!PyArg_ParseTuple (args, FORMAT_STRING, &buf, &length, &offset)) return NULL; if (offset + length > buffer->length) @@ -266,6 +273,8 @@ memcpy (((Uint8 *)buffer->buffer) + offset, buf, (size_t) length); Py_RETURN_NONE; + +#undef FORMAT_STRING } /**** Buffer interfaces ****/
