diff -r 180f5bf7d1b9 Lib/test/regrtest.py --- a/Lib/test/regrtest.py Thu Sep 11 14:33:02 2014 +0300 +++ b/Lib/test/regrtest.py Thu Sep 11 19:05:27 2014 +0300 @@ -1031,7 +1031,7 @@ # to a thread, so check processes first. 'multiprocessing.process._dangling', 'threading._dangling', 'sysconfig._CONFIG_VARS', 'sysconfig._INSTALL_SCHEMES', - 'support.TESTFN', 'locale', 'warnings.showwarning', + 'files', 'locale', 'warnings.showwarning', ) def get_sys_argv(self): @@ -1187,20 +1187,24 @@ sysconfig._INSTALL_SCHEMES.clear() sysconfig._INSTALL_SCHEMES.update(saved[2]) - def get_support_TESTFN(self): - if os.path.isfile(support.TESTFN): - result = 'f' - elif os.path.isdir(support.TESTFN): - result = 'd' - else: - result = None - return result - def restore_support_TESTFN(self, saved_value): - if saved_value is None: - if os.path.isfile(support.TESTFN): - os.unlink(support.TESTFN) - elif os.path.isdir(support.TESTFN): - shutil.rmtree(support.TESTFN) + def get_files(self): + return sorted(fn + ('/' if os.path.isdir(fn) else '') + for fn in os.listdir()) + def restore_files(self, saved_value): + for fn in os.listdir(): + # It is not safe to remove files with names not starting with + # TESTFN, they can be created by other program. + if fn.startswith(support.TESTFN): + try: + if os.path.isdir(fn): + if fn + '/' not in saved_value: + support.rmtree(fn) + else: + if fn not in saved_value: + support.unlink(fn) + except OSError: + pass + _lc = [getattr(locale, lc) for lc in dir(locale) if lc.startswith('LC_')]