mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
_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. :-)
This commit is contained in:
parent
798654fc68
commit
58a88b3e34
1 changed files with 5 additions and 0 deletions
|
@ -162,8 +162,13 @@ else:
|
||||||
def __init__(self, environ):
|
def __init__(self, environ):
|
||||||
UserDict.UserDict.__init__(self)
|
UserDict.UserDict.__init__(self)
|
||||||
self.data = environ
|
self.data = environ
|
||||||
|
def __getinitargs__(self):
|
||||||
|
import copy
|
||||||
|
return (copy.copy(self.data),)
|
||||||
def __setitem__(self, key, item):
|
def __setitem__(self, key, item):
|
||||||
putenv(key, item)
|
putenv(key, item)
|
||||||
self.data[key] = item
|
self.data[key] = item
|
||||||
|
def __copy__(self):
|
||||||
|
return _Environ(self.data.copy())
|
||||||
|
|
||||||
environ = _Environ(environ)
|
environ = _Environ(environ)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue