[PATCH 2 of 6] imported patch mpatch.c-py3k-port.diff
Matt Mackall
mpm at selenic.com
Tue Jun 8 19:41:04 CDT 2010
On Tue, 2010-06-08 at 14:57 -0300, Renato Cunha wrote:
> # HG changeset patch
> # User Renato Cunha <renatoc at gmail.com>
> # Date 1276015325 10800
> # Node ID 6161c0ce8de625954cb7e45ed0a7e08d1b87f8ba
> # Parent 09df6346efc7d8fed0d2195f486a368af679d771
> imported patch mpatch.c-py3k-port.diff
>
> diff --git a/mercurial/mpatch.c b/mercurial/mpatch.c
> --- a/mercurial/mpatch.c
> +++ b/mercurial/mpatch.c
> @@ -32,6 +32,8 @@
> typedef int Py_ssize_t;
> #define PY_SSIZE_T_MAX INT_MAX
> #define PY_SSIZE_T_MIN INT_MIN
> +#elif PY_MAJOR_VERSION >= 3
> +#define IS_PY3K
> #endif
> #ifdef _WIN32
> @@ -373,12 +375,20 @@
> result = NULL;
> goto cleanup;
> }
> +#ifdef IS_PY3K
> + result = PyBytes_FromStringAndSize(NULL, outlen);
> +#else
> result = PyString_FromStringAndSize(NULL, outlen);
> +#endif
> if (!result) {
> result = NULL;
> goto cleanup;
> }
> +#ifdef IS_PY3K
> + out = PyBytes_AsString(result);
> +#else
> out = PyString_AsString(result);
> +#endif
> if (!apply(out, in, inlen, patch)) {
> Py_DECREF(result);
> result = NULL;
> @@ -435,10 +445,34 @@
> {NULL, NULL}
> };
Seems like it's time we added a util.h to hide a bunch of this stuff.
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list