]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
backport my checkin of
authorMichael W. Hudson <mwh@python.net>
Thu, 7 Mar 2002 10:12:11 +0000 (10:12 +0000)
committerMichael W. Hudson <mwh@python.net>
Thu, 7 Mar 2002 10:12:11 +0000 (10:12 +0000)
    revision 1.52 of os.py

revision 1.52
date: 2002/03/06 17:11:17;  author: mwh;  state: Exp;  lines: +20 -0
Special support for pickling os.stat and os.stat_vfs results portably
(the types come from different modules on different platforms).

Added tests for pickling these types.

May be a bugfix candidate.

Lib/os.py

index bf31ddcce0df47a045b9662382621d94a962bed6..6ffd9cb787f6160581b85d9d355dada5a860a714 100644 (file)
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -591,3 +591,23 @@ if _exists("fork"):
             stdout, stdin = popen2.popen4(cmd, bufsize)
             return stdin, stdout
         __all__.append("popen4")
+
+import copy_reg as _copy_reg
+
+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)
+
+_copy_reg.pickle(stat_result, _pickle_stat_result,_make_stat_result)
+
+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)
+
+_copy_reg.pickle(statvfs_result, _pickle_statvfs_result,_make_statvfs_result)