public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  tromey/python: Fix Python3 compatibility.
@ 2015-02-04 16:28 jkratoch
  0 siblings, 0 replies; only message in thread
From: jkratoch @ 2015-02-04 16:28 UTC (permalink / raw)
  To: archer-commits

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 <jan.kratochvil@redhat.com>
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.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-02-04 16:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-04 16:28 [SCM] tromey/python: Fix Python3 compatibility jkratoch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).