[doc] Python3: execfile->exec+open

Message ID 20150815052744.GA4688@host1.jankratochvil.net
State New, archived
Headers

Commit Message

Jan Kratochvil Aug. 15, 2015, 5:27 a.m. UTC
  Hi,

https://bugzilla.redhat.com/show_bug.cgi?id=1253590

https://docs.python.org/3.3/whatsnew/3.0.html#builtins

Python 2 had:
	gdb -ex 'python execfile("foo.py")'
but Python3 has only:
	gdb -ex 'python exec(open("foo.py").read())'
Fortunately the Python3 way works even in Python2.

execfile is used also in 'gdb/contrib/exsummary.py' but I expect there may be
more issues of Python2->3 compatibility than this one, I haven't found it easy
to test it and it was contributed by Tom Tromey who does not contribute
patches here anymore.  Given it is in contrib/ I do not find it a problem.


Jan
gdb/doc/ChangeLog
2015-08-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* python.texi (Python Commands): Change python execfile to exec+open.
  

Patch

diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index a2df254..7231c2c 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -114,8 +114,8 @@  The script name must end with @samp{.py} and @value{GDBN} must be configured
 to recognize the script language based on filename extension using
 the @code{script-extension} setting.  @xref{Extending GDB, ,Extending GDB}.
 
-@item python execfile ("script-name")
-This method is based on the @code{execfile} Python built-in function,
+@item python exec (open ("script-name").read ())
+This method is based on the @code{exec} Python built-in function,
 and thus is always available.
 @end table