Red Hat Bugzilla – Bug 1253590
'python execfile("script-name")' no longer works
Last modified: 2016-11-30 19:49:08 EST
Description of problem:
When I was investigating an uncaught Python exception generated by ABRT when it was processing a new core file, I found out that 'gdb python execfile("script-name")' no longer works.
This is probably caused by the fact that 'execfile' was removed from Python 3 and users are supposed to use 'exec(open("script-name").read())' .
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. gdb -ex "python execfile ('/usr/libexec/abrt-gdb-exploitable')"
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'execfile' is not defined
Error while executing Python code.
No exception raised by Python.
The following command works as expected but it looks weird:
$ gdb -ex "python exec(open("/usr/libexec/abrt-gdb-exploitable").read())"
This is a Python change, I find it unrelated to GDB. You can use that exec(open(...).read()) form as you wrote.
The only GDB bug I see that GDB Manual uses 'python execfile' in one example so the doc should be changed.
Otherwise I do not see what to change - or do you? Thanks for the bugreport.
(In reply to Jan Kratochvil from comment #1)
> Otherwise I do not see what to change - or do you? Thanks for the bugreport.
Me too. My intention was to write a public note that could be found by gdb users who hit the same issue.