New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
os.environ.pop doesn't work #45628
Comments
0
>>> os.environ["ASD"] = "asd"
>>> os.system("echo $ASD")
asd
0
>>> os.environ.pop("ASD")
'asd'
>>> os.system("echo $ASD")
asd
0 |
The following patch solves the problem (with the latest from trunk). I =================================================================== --- Lib/os.py (revision 58221)
+++ Lib/os.py (working copy)
@@ -446,6 +446,9 @@
def __delitem__(self, key):
unsetenv(key)
del self.data[key.upper()]
+ def pop(self, key):
+ unsetenv(key)
+ return UserDict.IterableUserDict.pop(self, key)
def clear(self):
for key in self.data.keys():
unsetenv(key)
@@ -513,6 +516,9 @@
del self.data[key]
def copy(self):
return dict(self)
+ def pop(self, key):
+ unsetenv(key)
+ return UserDict.IterableUserDict.pop(self, key)
environ = _Environ(environ) |
Fixed in r58651 for 2.6. |
After reading the change, I think one more small change may be required. Index: Lib/os.py --- Lib/os.py (revision 58654)
+++ Lib/os.py (working copy)
@@ -452,7 +452,7 @@
del self.data[key]
def pop(self, key, *args):
unsetenv(key)
- return self.data.pop(key, *args)
+ return self.data.pop(key.upper(), *args)
def has_key(self, key):
return key.upper() in self.data
def __contains__(self, key): |
You're right, fixed that in r58675. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: