Bug 1253590 - 'python execfile("script-name")' no longer works
'python execfile("script-name")' no longer works
Product: Fedora
Classification: Fedora
Component: gdb (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Jan Kratochvil
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2015-08-14 04:04 EDT by Jakub Filak
Modified: 2016-11-30 19:49 EST (History)
7 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2015-08-15 01:29:14 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Jakub Filak 2015-08-14 04:04:35 EDT
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):

How reproducible:

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 08:02:57 EDT
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 09:01:27 EDT
(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.

Note You need to log in before you can comment on or make changes to this bug.