diff options
author | Charles Burkland <charles.abucher@gmail.com> | 2020-03-13 16:04:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-13 16:04:43 (GMT) |
commit | d648ef10c5c7659ed3c9f34d5c751dc55e2c6007 (patch) | |
tree | e8cbea457b659acde56f062bdc6b09856bd66d61 /Lib/os.py | |
parent | 38965ec5411da60d312b59be281f3510d58e0cf1 (diff) | |
download | cpython-d648ef10c5c7659ed3c9f34d5c751dc55e2c6007.zip cpython-d648ef10c5c7659ed3c9f34d5c751dc55e2c6007.tar.gz cpython-d648ef10c5c7659ed3c9f34d5c751dc55e2c6007.tar.bz2 |
bpo-36144: Update os.environ and os.environb for PEP 584 (#18911)
Diffstat (limited to 'Lib/os.py')
-rw-r--r-- | Lib/os.py | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -659,7 +659,7 @@ def get_exec_path(env=None): # Change environ to automatically call putenv() and unsetenv() -from _collections_abc import MutableMapping +from _collections_abc import MutableMapping, Mapping class _Environ(MutableMapping): def __init__(self, data, encodekey, decodekey, encodevalue, decodevalue): @@ -714,6 +714,24 @@ class _Environ(MutableMapping): self[key] = value return self[key] + def __ior__(self, other): + self.update(other) + return self + + def __or__(self, other): + if not isinstance(other, Mapping): + return NotImplemented + new = dict(self) + new.update(other) + return new + + def __ror__(self, other): + if not isinstance(other, Mapping): + return NotImplemented + new = dict(other) + new.update(self) + return new + def _createenviron(): if name == 'nt': # Where Env Var Names Must Be UPPERCASE |