Created attachment 31135 [details] Patch to update raise statements to modern Python syntax The pretty printers shipped with GCC 4.8.1 use the obsolete raise ExceptionClass, argument format for raising exceptions. Modern Python (not sure when it was introduced, but the Python 2.6 docs seems to support it so it has been around for a while) instead uses raise ExceptionClass(arguments...) and the old form is not supported in Python 3. The result is that when I try to load the pretty printers via .gdbinit in Ubuntu 13.10, I get this message: Traceback (most recent call last): File "<string>", line 3, in <module> File "/usr/share/gcc-4.8/python/libstdcxx/v6/printers.py", line 54 raise ValueError, "Cannot find type %s::%s" % (str(orig), name) ^ SyntaxError: invalid syntax /home/bruce/.gdbinit:7: Error in sourced command file: Error while executing Python code. I've attached a patch which changes the raise statements to use the new syntax. It's against the version shipped with Ubuntu 13.10 in libstdc++6-4.8-dbg; I haven't checked whether Ubuntu have added their own patches.
I've now realised that this is actually just the tip of the iceberg - I suspect that libstdc++'s pretty printers aren't Python 3 ready, while Ubuntu is shipping a gdb linked to libython 3.3. Feel free to close if this is as expected.
Please, assign it to me.
Please do not close this issue.(In reply to Bruce Merry from comment #1) > I've now realised that this is actually just the tip of the iceberg - I > suspect that libstdc++'s pretty printers aren't Python 3 ready, while Ubuntu > is shipping a gdb linked to libython 3.3. Feel free to close if this is as > expected. Please don't close this issue, it is completely relevant since not only for ubuntu but for other distros too. Syntax should work both with python versions 2 and 3 at ever possible.
Incidentally, the workaround I have been using is to just run the script through 2to3. Since Python only tells you things have gone wrong when you execute the code I can't guarantee that this fixes everything, but I've yet to hit any further Python 2 vs 3 issues after doing this.
Author: redi Date: Fri Jul 11 13:43:07 2014 New Revision: 212453 URL: https://gcc.gnu.org/viewcvs?rev=212453&root=gcc&view=rev Log: 2014-07-11 Samuel Bronson <naesten@gmail.com> Matthias Klose <doko@ubuntu.com> PR libstdc++/58962 * python/libstdcxx/v6/printers.py: Port to Python 2+3 (imap): New compat function. (izip): Likewise. (Iterator): New mixin to allow writing iterators in Python 3 style regardless of which version we're running on. [Python3] (long) New compat alias for "int". * testsuite/lib/gdb-test.exp: Port to Python 2+3 (print syntax) Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/python/libstdcxx/v6/printers.py trunk/libstdc++-v3/testsuite/lib/gdb-test.exp
The trunk version of the printers should now work with both Python 2 and 3
Author: redi Date: Mon Aug 4 18:50:30 2014 New Revision: 213604 URL: https://gcc.gnu.org/viewcvs?rev=213604&root=gcc&view=rev Log: 2014-08-04 Samuel Bronson <naesten@gmail.com> Backport r212453 from trunk 2014-07-11 Samuel Bronson <naesten@gmail.com> Matthias Klose <doko@ubuntu.com> PR libstdc++/58962 * python/libstdcxx/v6/printers.py: Port to Python 2+3 (imap): New compat function. (izip): Likewise. (Iterator): New mixin to allow writing iterators in Python 3 style regardless of which version we're running on. [Python3] (long) New compat alias for "int". * testsuite/lib/gdb-test.exp: Port to Python 2+3 (print syntax) Backport r210625 from trunk 2014-05-19 Jonathan Wakely <jwakely@redhat.com> * python/libstdcxx/v6/printers.py: Use Python3 raise syntax. Modified: branches/gcc-4_9-branch/libstdc++-v3/ChangeLog branches/gcc-4_9-branch/libstdc++-v3/python/libstdcxx/v6/printers.py branches/gcc-4_9-branch/libstdc++-v3/testsuite/lib/gdb-test.exp
backported for 4.9.2
Author: redi Date: Thu Aug 28 16:22:21 2014 New Revision: 214682 URL: https://gcc.gnu.org/viewcvs?rev=214682&root=gcc&view=rev Log: 2014-08-28 Samuel Bronson <naesten@gmail.com> Backport r212453 from trunk 2014-07-11 Samuel Bronson <naesten@gmail.com> Matthias Klose <doko@ubuntu.com> PR libstdc++/58962 * python/libstdcxx/v6/printers.py: Port to Python 2+3 (imap): New compat function. (izip): Likewise. (Iterator): New mixin to allow writing iterators in Python 3 style regardless of which version we're running on. [Python3] (long) New compat alias for "int". * testsuite/lib/gdb-test.exp: Port to Python 2+3 (print syntax) Backport r210625 from trunk 2014-05-19 Jonathan Wakely <jwakely@redhat.com> * python/libstdcxx/v6/printers.py: Use Python3 raise syntax. Modified: branches/gcc-4_8-branch/libstdc++-v3/ChangeLog branches/gcc-4_8-branch/libstdc++-v3/python/libstdcxx/v6/printers.py branches/gcc-4_8-branch/libstdc++-v3/testsuite/lib/gdb-test.exp