This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: python-2.4 compat. [Re: [patch][python] 1 of 5 - Frame filter Python C code changes.]
- From: Phil Muldoon <pmuldoon at redhat dot com>
- To: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- Cc: Tom Tromey <tromey at redhat dot com>, "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Thu, 12 Sep 2013 08:56:52 +0100
- Subject: Re: python-2.4 compat. [Re: [patch][python] 1 of 5 - Frame filter Python C code changes.]
- Authentication-results: sourceware.org; auth=none
- References: <5187686B dot 5010809 at redhat dot com> <87txmfx2qd dot fsf at fleche dot redhat dot com> <518BA33B dot 9030405 at redhat dot com> <87bo8kqj6c dot fsf at fleche dot redhat dot com> <518CCF0C dot 6060704 at redhat dot com> <20130912073646 dot GB13948 at host2 dot jankratochvil dot net>
On 12/09/13 08:36, Jan Kratochvil wrote:
> On Fri, 10 May 2013 12:42:20 +0200, Phil Muldoon wrote:
> [...]
>> --- /dev/null
>> +++ b/gdb/python/lib/gdb/command/frame_filters.py
>> @@ -0,0 +1,461 @@
> [...]
>> + for frame_filter in sorted_frame_filters:
>> + name = frame_filter[0]
>> + try:
>> + priority = '{:<8}'.format(
>> + str(gdb.frames.get_priority(frame_filter[1])))
>> + enabled = '{:<7}'.format(
>> + self.enabled_string(gdb.frames.get_enabled(frame_filter[1])))
>> + except Exception as e:
>> + print(" Error printing filter '"+name+"': "+str(e))
>> + else:
>> + print(" %s %s %s" % (priority, enabled, name))
> (plus it is there once again later)
>
> CentOS-5 python-2.4.3-56.el5.x86_64:
>
> ./gdb -nx -data-directory ./data-directoryTraceback (most recent call last):
> File ".../gdb/testsuite/../data-directory/python/gdb/__init__.py", line 105, in auto_load_packages
> __import__(modname)
> File "./data-directory/python/gdb/command/frame_filters.py", line 82
> except Exception as e:
> ^
> SyntaxError: invalid syntax
>
> GNU gdb (GDB) 7.6.50.20130912-cvs
>
> IIRC it was agreed upon upstream FSF GDB should support python-2.4, could you
> code it in a compatible way?
To write this so it works in Python 2.4 -> Python 3.x I will have to
write it as:
except Exception:
e = sys.exc_info()[1]
....
That's fine - I will do that. But I think it is kind of silly to do
stuff like this in Python - we are just circumventing how Exceptions
should be written to support a broad subset of Python versions.
The differences between 2.4 and 2.7, and 3.x and everything in-between
are just becoming a major pain to maintain, and harder to review. At
some point we should discuss, for future GDB releases, our strategy
for Python versions. I just see in the future incompatibilities we
can't write around being replaced with:
if sys.version >= 2.4 and sys.version <= 2.7:
....
else if sys.version > 2.7:
....
Which is just the moral equivalent of #ifdef'ness in C. Not to
mention the same equivalent in the Python C code in GDB.
Cheers,
Phil