mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
bpo-36144: Update os.environ and os.environb for PEP 584 (#18911)
This commit is contained in:
parent
38965ec541
commit
d648ef10c5
5 changed files with 118 additions and 1 deletions
20
Lib/os.py
20
Lib/os.py
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue