From: Phil Muldoon <pmuldoon@redhat.com>
To: gdb-patches@sourceware.org
Subject: [python] [patch] PR python/13345
Date: Mon, 31 Oct 2011 18:11:00 -0000 [thread overview]
Message-ID: <m37h3lupk2.fsf@redhat.com> (raw)
This patch fixes a case where the tilde (~) command was being passed to
Python via the "source" command. Python does not understand what to do
with a tilde, so we have to expand it first.
OK?
Cheers,
Phil
--
2011-10-31 Phil Muldoon <pmuldoon@redhat.com>
PR Python/13345
* python/python.c (python_run_simple_file): Expand tilde in path.
--
Index: python/python.c
===================================================================
RCS file: /cvs/src/src/gdb/python/python.c,v
retrieving revision 1.75
diff -u -r1.75 python.c
--- python/python.c 7 Oct 2011 07:38:30 -0000 1.75
+++ python/python.c 31 Oct 2011 15:42:19 -0000
@@ -30,6 +30,7 @@
#include "exceptions.h"
#include "event-loop.h"
#include "serial.h"
+#include "readline/tilde.h"
#include "python.h"
#include <ctype.h>
@@ -162,13 +163,22 @@
static void
python_run_simple_file (const char *filename)
{
- char *filename_copy;
+ char *full_path;
PyObject *python_file;
struct cleanup *cleanup;
- filename_copy = xstrdup (filename);
- cleanup = make_cleanup (xfree, filename_copy);
- python_file = PyFile_FromString (filename_copy, "r");
+ /* Because we have a string for a filename, and are using Python to
+ open the file, we need to expand any tilde in the path first. */
+ full_path = tilde_expand (filename);
+ cleanup = make_cleanup (xfree, full_path);
+ python_file = PyFile_FromString (full_path, "r");
+ if (! python_file)
+ {
+ do_cleanups (cleanup);
+ gdbpy_print_stack ();
+ error (_("Error sourcing Python file"));
+ }
+
make_cleanup_py_decref (python_file);
PyRun_SimpleFile (PyFile_AsFile (python_file), filename);
do_cleanups (cleanup);
next reply other threads:[~2011-10-31 15:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-31 18:11 Phil Muldoon [this message]
2011-11-01 14:07 ` Meador Inge
2011-11-01 14:15 ` Phil Muldoon
2011-11-01 18:06 ` Meador Inge
2011-11-01 17:53 ` Tom Tromey
2011-11-01 18:55 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m37h3lupk2.fsf@redhat.com \
--to=pmuldoon@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox