2011-11-04 Phil Muldoon <pmuldoon@redhat.com>
PR Python/13345 * python/python.c (python_run_simple_file): Expand tilde in path.
This commit is contained in:
parent
cd829959ce
commit
3ab1ec2776
2 changed files with 20 additions and 4 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2011-11-04 Phil Muldoon <pmuldoon@redhat.com>
|
||||||
|
|
||||||
|
PR Python/13345
|
||||||
|
|
||||||
|
* python/python.c (python_run_simple_file): Expand tilde in path.
|
||||||
|
|
||||||
2011-11-04 Phil Muldoon <pmuldoon@redhat.com>
|
2011-11-04 Phil Muldoon <pmuldoon@redhat.com>
|
||||||
|
|
||||||
PR Python/13363
|
PR Python/13363
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "exceptions.h"
|
#include "exceptions.h"
|
||||||
#include "event-loop.h"
|
#include "event-loop.h"
|
||||||
#include "serial.h"
|
#include "serial.h"
|
||||||
|
#include "readline/tilde.h"
|
||||||
#include "python.h"
|
#include "python.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -162,13 +163,22 @@ ensure_python_env (struct gdbarch *gdbarch,
|
||||||
static void
|
static void
|
||||||
python_run_simple_file (const char *filename)
|
python_run_simple_file (const char *filename)
|
||||||
{
|
{
|
||||||
char *filename_copy;
|
char *full_path;
|
||||||
PyObject *python_file;
|
PyObject *python_file;
|
||||||
struct cleanup *cleanup;
|
struct cleanup *cleanup;
|
||||||
|
|
||||||
filename_copy = xstrdup (filename);
|
/* Because we have a string for a filename, and are using Python to
|
||||||
cleanup = make_cleanup (xfree, filename_copy);
|
open the file, we need to expand any tilde in the path first. */
|
||||||
python_file = PyFile_FromString (filename_copy, "r");
|
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 while opening file: %s"), full_path);
|
||||||
|
}
|
||||||
|
|
||||||
make_cleanup_py_decref (python_file);
|
make_cleanup_py_decref (python_file);
|
||||||
PyRun_SimpleFile (PyFile_AsFile (python_file), filename);
|
PyRun_SimpleFile (PyFile_AsFile (python_file), filename);
|
||||||
do_cleanups (cleanup);
|
do_cleanups (cleanup);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue