Bug 1253590 - 'python execfile("script-name")' no longer works
Summary: 'python execfile("script-name")' no longer works
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: gdb
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jan Kratochvil
QA Contact: Fedora Extras Quality Assurance
URL: https://sourceware.org/ml/gdb-patches...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-08-14 08:04 UTC by Jakub Filak
Modified: 2016-12-01 00:49 UTC (History)
7 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2015-08-15 05:29:14 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

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.


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