Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
8fec4891
Commit
8fec4891
authored
Sep 20, 2007
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch #1181: add os.environ.clear() method.
parent
10e21bf1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
Doc/library/os.rst
Doc/library/os.rst
+6
-2
Lib/os.py
Lib/os.py
+8
-0
No files found.
Doc/library/os.rst
View file @
8fec4891
...
...
@@ -115,9 +115,13 @@ process and user.
passed to the appropriate process-creation functions to cause child processes
to use a modified environment.
If the platform supports the :func:`unsetenv` function, you can
delete items in
If the platform supports the :func:`unsetenv` function, you can delete items in
this mapping to unset environment variables. :func:`unsetenv` will be called
automatically when an item is deleted from ``os.environ``.
automatically when an item is deleted from ``os.environ``, and when
:meth:`os.environ.clear` is called.
.. versionchanged:: 2.6
Also unset environment variables when calling :meth:`os.environ.clear`.
.. function:: chdir(path)
...
...
Lib/os.py
View file @
8fec4891
...
...
@@ -446,6 +446,10 @@ else:
def
__delitem__
(
self
,
key
):
unsetenv
(
key
)
del
self
.
data
[
key
.
upper
()]
def
clear
(
self
):
for
key
in
self
.
data
.
keys
():
unsetenv
(
key
)
del
self
.
data
[
key
]
def
has_key
(
self
,
key
):
return
key
.
upper
()
in
self
.
data
def
__contains__
(
self
,
key
):
...
...
@@ -503,6 +507,10 @@ else:
def
__delitem__
(
self
,
key
):
unsetenv
(
key
)
del
self
.
data
[
key
]
def
clear
(
self
):
for
key
in
self
.
data
.
keys
():
unsetenv
(
key
)
del
self
.
data
[
key
]
def
copy
(
self
):
return
dict
(
self
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment