From: Barry Warsaw Date: Mon, 1 Dec 1997 04:30:19 +0000 (+0000) Subject: _Environ(): Added __getinitargs__() method so os.environ.copy() works, X-Git-Tag: v1.5b2~154 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58a88b3e34f7b992a33ee93001bf6d795acd7f32;p=thirdparty%2FPython%2Fcpython.git _Environ(): Added __getinitargs__() method so os.environ.copy() works, as does unpickling, as in: pickle.loads(pickle.dumps(os.environ)). Hope this is right! Don't shoot me Guido. :-) --- diff --git a/Lib/os.py b/Lib/os.py index 16d0af9240e6..2776cd7c670a 100644 --- a/Lib/os.py +++ b/Lib/os.py @@ -162,8 +162,13 @@ else: def __init__(self, environ): UserDict.UserDict.__init__(self) self.data = environ + def __getinitargs__(self): + import copy + return (copy.copy(self.data),) def __setitem__(self, key, item): putenv(key, item) self.data[key] = item + def __copy__(self): + return _Environ(self.data.copy()) environ = _Environ(environ)