From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21481 invoked by alias); 4 Feb 2015 16:28:35 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 21462 invoked by uid 9674); 4 Feb 2015 16:28:34 -0000 Date: Wed, 04 Feb 2015 16:28:00 -0000 Message-ID: <20150204162834.21435.qmail@sourceware.org> From: jkratoch@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] tromey/python: Fix Python3 compatibility. X-Git-Refname: refs/heads/tromey/python X-Git-Reftype: branch X-Git-Oldrev: ef5e5e4d5bfedecf54ef7f1380eaf89662b617d0 X-Git-Newrev: 55b3f8bf6f2ecf9b4f7115d9cf7a34cc1fd9593f X-SW-Source: 2015-q1/txt/msg00002.txt.bz2 List-Id: The branch, tromey/python has been updated via 55b3f8bf6f2ecf9b4f7115d9cf7a34cc1fd9593f (commit) from ef5e5e4d5bfedecf54ef7f1380eaf89662b617d0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 55b3f8bf6f2ecf9b4f7115d9cf7a34cc1fd9593f Author: Jan Kratochvil Date: Wed Feb 4 17:28:20 2015 +0100 Fix Python3 compatibility. ----------------------------------------------------------------------- Summary of changes: gdb/python/python.c | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-) First 500 lines of diff: diff --git a/gdb/python/python.c b/gdb/python/python.c index 8eb8afe..54a2d9b 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -1258,7 +1258,34 @@ run_python_script (int argc, char **argv) ensure_python_env (get_current_arch (), current_language); running_python_script = 1; + +#if PYTHON_ABI_VERSION < 3 PySys_SetArgv (argc - 1, argv + 1); +#else + { + wchar_t **wargv = alloca (sizeof (*wargv) * (argc + 1)); + int i; + + for (i = 1; i < argc; i++) + { + size_t len = mbstowcs (NULL, argv[i], 0); + size_t len2; + + if (len == (size_t) -1) + { + fprintf (stderr, "Invalid multibyte argument #%d \"%s\"\n", + i, argv[i]); + exit (1); + } + wargv[i] = alloca (sizeof (**wargv) * (len + 1)); + len2 = mbstowcs (wargv[i], argv[i], len + 1); + assert (len2 == len); + } + wargv[argc] = NULL; + PySys_SetArgv (argc - 1, wargv + 1); + } +#endif + input = fopen (argv[0], "r"); if (! input) { hooks/post-receive -- Repository for Project Archer.