Index: Lib/pdb.py =================================================================== --- Lib/pdb.py (revision 77684) +++ Lib/pdb.py (working copy) @@ -1218,7 +1218,7 @@ 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: Lib/test/test_pdb.py =================================================================== --- Lib/test/test_pdb.py (revision 77684) +++ Lib/test/test_pdb.py (working copy) @@ -5,6 +5,8 @@ import os import sys import doctest +import unittest +import subprocess import tempfile from test import test_support @@ -128,7 +130,29 @@ (Pdb) continue """ +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 test_support.run_doctest(test_pdb, verbosity=True) @@ -136,3 +160,4 @@ if __name__ == '__main__': test_main() + unittest.main()