Bug 1253590

Summary: 'python execfile("script-name")' no longer works
Product: [Fedora] Fedora Reporter: Jakub Filak <jfilak>
Component: gdbAssignee: Jan Kratochvil <jan.kratochvil>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: gbenson, jan.kratochvil, jberan, palves, pmuldoon, sergiodj, tom
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
URL: https://sourceware.org/ml/gdb-patches/2015-08/msg00400.html
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-08-15 05:29:14 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jakub Filak 2015-08-14 08:04:35 UTC
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())' [1].

Version-Release number of selected component (if applicable):
gdb-7.9.90.20150717-12.fc24.x86_64

How reproducible:
Always

Steps to Reproduce:
1. gdb -ex "python execfile ('/usr/libexec/abrt-gdb-exploitable')"

Actual results:
...
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'execfile' is not defined
Error while executing Python code.
...

Expected results:
No exception raised by Python.

Additional info:
The following command works as expected but it looks weird:
$ gdb -ex "python exec(open("/usr/libexec/abrt-gdb-exploitable").read())"


[1]: https://docs.python.org/3.3/whatsnew/3.0.html?highlight=execfile#builtins

Comment 1 Jan Kratochvil 2015-08-14 12:02:57 UTC
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.

Comment 2 Jakub Filak 2015-08-14 13:01:27 UTC
(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.