diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/os.py | 27 | ||||
-rw-r--r-- | Lib/test/test_os.py | 22 | ||||
-rw-r--r-- | Lib/test/test_site.py | 5 |
3 files changed, 26 insertions, 28 deletions
@@ -945,33 +945,6 @@ otherwise return -SIG, where SIG is the signal that killed it. """ __all__.extend(["spawnlp", "spawnlpe"]) -import copyreg as _copyreg - -def _make_stat_result(tup, dict): - return stat_result(tup, dict) - -def _pickle_stat_result(sr): - (type, args) = sr.__reduce__() - return (_make_stat_result, args) - -try: - _copyreg.pickle(stat_result, _pickle_stat_result, _make_stat_result) -except NameError: # stat_result may not exist - pass - -def _make_statvfs_result(tup, dict): - return statvfs_result(tup, dict) - -def _pickle_statvfs_result(sr): - (type, args) = sr.__reduce__() - return (_make_statvfs_result, args) - -try: - _copyreg.pickle(statvfs_result, _pickle_statvfs_result, - _make_statvfs_result) -except NameError: # statvfs_result may not exist - pass - # Supply os.popen() def popen(cmd, mode="r", buffering=-1): if not isinstance(cmd, str): diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 39b0e80..ab44d01 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -26,6 +26,7 @@ import locale import codecs import decimal import fractions +import pickle try: import threading except ImportError: @@ -264,6 +265,13 @@ class StatAttributeTests(unittest.TestCase): warnings.simplefilter("ignore", DeprecationWarning) self.check_stat_attributes(fname) + def test_stat_result_pickle(self): + result = os.stat(self.fname) + p = pickle.dumps(result) + self.assertIn(b'\x03cos\nstat_result\n', p) + unpickled = pickle.loads(p) + self.assertEqual(result, unpickled) + def test_statvfs_attributes(self): if not hasattr(os, "statvfs"): return @@ -310,6 +318,20 @@ class StatAttributeTests(unittest.TestCase): except TypeError: pass + @unittest.skipUnless(hasattr(os, 'statvfs'), + "need os.statvfs()") + def test_statvfs_result_pickle(self): + try: + result = os.statvfs(self.fname) + except OSError as e: + # On AtheOS, glibc always returns ENOSYS + if e.errno == errno.ENOSYS: + return + p = pickle.dumps(result) + self.assertIn(b'\x03cos\nstatvfs_result\n', p) + unpickled = pickle.loads(p) + self.assertEqual(result, unpickled) + def test_utime_dir(self): delta = 1000000 st = os.stat(support.TESTFN) diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py index d260603..5147edc 100644 --- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -431,10 +431,13 @@ class StartupImportTests(unittest.TestCase): modules = eval(stdout.decode('utf-8')) self.assertIn('site', modules) + # http://bugs.python.org/issue19205 re_mods = {'re', '_sre', 'sre_compile', 'sre_constants', 'sre_parse'} self.assertFalse(modules.intersection(re_mods)) - + # http://bugs.python.org/issue9548 self.assertNotIn('locale', modules) + # http://bugs.python.org/issue19209 + self.assertNotIn('copyreg', modules) if __name__ == "__main__": |