]> granicus.if.org Git - python/commitdiff
PDB now will properly escape backslashes in the names of modules it executes. Fixes...
authorJason R. Coombs <jaraco@jaraco.com>
Thu, 17 Nov 2011 23:03:24 +0000 (18:03 -0500)
committerJason R. Coombs <jaraco@jaraco.com>
Thu, 17 Nov 2011 23:03:24 +0000 (18:03 -0500)
Lib/pdb.py
Lib/test/test_pdb.py

index a6109d45e8432e0f2e1cb37e94c0ea74c9a45f9f..5468d3fcaff88c22d0be9d14e34f89c18a30a303 100755 (executable)
@@ -1229,7 +1229,7 @@ see no sign that the breakpoint was reached.
         self._wait_for_mainpyfile = 1
         self.mainpyfile = self.canonic(filename)
         self._user_requested_quit = 0
-        statement = 'execfile( "%s")' % filename
+        statement = 'execfile(%r)' % filename
         self.run(statement)
 
 # Simplified interface
index f03c20bcf9c9556680c282724f327ee27652ac0b..5b1f8f792a5dc0799165a3df857d7dfa228c0716 100644 (file)
@@ -3,6 +3,9 @@
 
 import imp
 import sys
+import os
+import unittest
+import subprocess
 
 from test import test_support
 # This little helper class is essential for testing pdb under doctest.
@@ -277,6 +280,29 @@ def test_pdb_continue_in_bottomframe():
     4
     """
 
+class Tester7750(unittest.TestCase):
+    # if the filename has something that resolves to a python
+    #  escape character (such as \t), it will fail
+    test_fn = '.\\test7750.py'
+
+    msg = "issue7750 only applies when os.sep is a backslash"
+    @unittest.skipUnless(os.path.sep == '\\', msg)
+    def test_issue7750(self):
+        with open(self.test_fn, 'w') as f:
+            f.write('print("hello world")')
+        cmd = [sys.executable, '-m', 'pdb', self.test_fn,]
+        proc = subprocess.Popen(cmd,
+            stdout=subprocess.PIPE,
+            stdin=subprocess.PIPE,
+            stderr=subprocess.STDOUT,
+            )
+        stdout, stderr = proc.communicate('quit\n')
+        self.assertNotIn('IOError', stdout, "pdb munged the filename")
+
+    def tearDown(self):
+        if os.path.isfile(self.test_fn):
+            os.remove(self.test_fn)
+
 
 def test_main():
     from test import test_pdb
@@ -285,3 +311,4 @@ def test_main():
 
 if __name__ == '__main__':
     test_main()
+    unittest.main()