This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author amaury.forgeotdarc
Recipients amaury.forgeotdarc, inducer, nlopes
Date 2009-06-22.21:34:55
SpamBayes Score 9.11545e-07
Marked as misclassified No
Message-id <1245706498.99.0.193981364904.issue6323@psf.upfronthosting.co.za>
In-reply-to
Content
Thanks for the test case.
It appears that 2.7 actually calls exec("execfile(filename)"),
when 3.1 directly calls exec(file_content).

The indirection seems necessary: the SyntaxError is detected by the pdb 
trace function; but this function has to run somehow...
With the patch below, pdb now runs exec("exec(file_content)").

I'm not sure how to write unit tests for pdb.
I don't know if it will be accepted for 3.1 final.

Index: Lib/pdb.py
===================================================================
--- Lib/pdb.py  (revision 73505)
+++ Lib/pdb.py  (working copy)
@@ -1211,7 +1211,7 @@
         self.mainpyfile = self.canonic(filename)
         self._user_requested_quit = 0
         with open(filename) as fp:
-            statement = fp.read()
+            statement = "exec(%r)" % (fp.read(),)
         self.run(statement)

 # Simplified interface
History
Date User Action Args
2009-06-22 21:34:59amaury.forgeotdarcsetrecipients: + amaury.forgeotdarc, inducer, nlopes
2009-06-22 21:34:58amaury.forgeotdarcsetmessageid: <1245706498.99.0.193981364904.issue6323@psf.upfronthosting.co.za>
2009-06-22 21:34:56amaury.forgeotdarclinkissue6323 messages
2009-06-22 21:34:55amaury.forgeotdarccreate