Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: pmuldoon@redhat.com
Cc: gdb-patches@sourceware.org
Subject: Re: [patch][python] Auto-load gdb.command and gdb.function modules
Date: Thu, 04 Aug 2011 17:12:00 -0000	[thread overview]
Message-ID: <m3liv9yucn.fsf@fleche.redhat.com> (raw)
In-Reply-To: <m3ty9xgluh.fsf@redhat.com> (Phil Muldoon's message of "Thu, 04	Aug 2011 17:52:54 +0100")

>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:

Phil> This patch enables module auto-importing for the gdb.command and
Phil> gdb.function name-spaces.  Any Python file (which is not __init__.py)
Phil> located in {data-directory}/gdb/python/command and
Phil> {data-directory}/gdb/python/function is now automatically imported, and
Phil> available immediately upon GDB start.

Phil> Tested on X86-64 with no regressions.

Phil> OK?

Phil> +module_dict = {\
Phil> +'gdb.function': os.path.join(gdb.PYTHONDIR, 'gdb', 'function'),\
Phil> +'gdb.command': os.path.join(gdb.PYTHONDIR, 'gdb', 'command')\
Phil> +}

You don't need the trailing "\"s, please remove them.
I think the lines in the dict should be indented, that looks better.

Phil> +     py_files = filter(lambda x: x.endswith('.py') and x != '__init__.py',\
Phil> +     os.listdir(location))

Indentation of the second line looks wrong.
I don't think you need that "\".

Phil> +     for py_file in py_files:
Phil> +       py_file = py_file.rstrip('.py')
Phil> +       py_file = module + '.' + py_file
Phil> +       try:
Phil> +         exec('import ' + py_file)
Phil> +       except:
Phil> +         print 'Error importing: ', py_file

It seems like this should print the real error from the exception.

Tom


  reply	other threads:[~2011-08-04 17:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-04 16:53 Phil Muldoon
2011-08-04 17:12 ` Tom Tromey [this message]
2011-08-04 18:31   ` Phil Muldoon
2011-08-04 18:59     ` Tom Tromey
2011-08-08 11:58       ` Phil Muldoon
2011-08-08 14:10         ` Eli Zaretskii
2011-08-09 12:46           ` Phil Muldoon

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=m3liv9yucn.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pmuldoon@redhat.com \
    /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