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
53853c3f
Commit
53853c3f
authored
Nov 22, 2011
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #13415: os.unsetenv() doesn't ignore errors anymore.
parent
6392d7f6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
1 deletion
+23
-1
Lib/test/test_os.py
Lib/test/test_os.py
+9
-0
Misc/NEWS
Misc/NEWS
+2
-0
Modules/posixmodule.c
Modules/posixmodule.c
+12
-1
No files found.
Lib/test/test_os.py
View file @
53853c3f
...
@@ -361,6 +361,15 @@ class EnvironTests(mapping_tests.BasicTestMappingProtocol):
...
@@ -361,6 +361,15 @@ class EnvironTests(mapping_tests.BasicTestMappingProtocol):
value
=
popen
.
read
().
strip
()
value
=
popen
.
read
().
strip
()
self
.
assertEqual
(
value
,
"World"
)
self
.
assertEqual
(
value
,
"World"
)
def
test_unset_error
(
self
):
if
sys
.
platform
==
"win32"
:
# an environment variable is limited to 32,767 characters
key
=
'x'
*
50000
else
:
# "=" is not allowed in a variable name
key
=
'key='
self
.
assertRaises
(
OSError
,
os
.
environ
.
__delitem__
,
key
)
class
WalkTests
(
unittest
.
TestCase
):
class
WalkTests
(
unittest
.
TestCase
):
"""Tests for os.walk()."""
"""Tests for os.walk()."""
...
...
Misc/NEWS
View file @
53853c3f
...
@@ -79,6 +79,8 @@ Core and Builtins
...
@@ -79,6 +79,8 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
13415
:
os
.
unsetenv
()
doesn
't ignore errors anymore.
- Issue #13322: Fix BufferedWriter.write() to ensure that BlockingIOError is
- Issue #13322: Fix BufferedWriter.write() to ensure that BlockingIOError is
raised when the wrapped raw file is non-blocking and the write would block.
raised when the wrapped raw file is non-blocking and the write would block.
Previous code assumed that the raw write() would raise BlockingIOError, but
Previous code assumed that the raw write() would raise BlockingIOError, but
...
...
Modules/posixmodule.c
View file @
53853c3f
...
@@ -6994,6 +6994,14 @@ posix_putenv(PyObject *self, PyObject *args)
...
@@ -6994,6 +6994,14 @@ posix_putenv(PyObject *self, PyObject *args)
/* XXX This can leak memory -- not easy to fix :-( */
/* XXX This can leak memory -- not easy to fix :-( */
len
=
strlen
(
s1
)
+
strlen
(
s2
)
+
2
;
len
=
strlen
(
s1
)
+
strlen
(
s2
)
+
2
;
#ifdef MS_WINDOWS
if
(
_MAX_ENV
<
(
len
-
1
))
{
PyErr_Format
(
PyExc_ValueError
,
"the environment variable is longer than %u bytes"
,
_MAX_ENV
);
return
NULL
;
}
#endif
/* len includes space for a trailing \0; the size arg to
/* len includes space for a trailing \0; the size arg to
PyString_FromStringAndSize does not count that */
PyString_FromStringAndSize does not count that */
newstr
=
PyString_FromStringAndSize
(
NULL
,
(
int
)
len
-
1
);
newstr
=
PyString_FromStringAndSize
(
NULL
,
(
int
)
len
-
1
);
...
@@ -7036,11 +7044,14 @@ static PyObject *
...
@@ -7036,11 +7044,14 @@ static PyObject *
posix_unsetenv
(
PyObject
*
self
,
PyObject
*
args
)
posix_unsetenv
(
PyObject
*
self
,
PyObject
*
args
)
{
{
char
*
s1
;
char
*
s1
;
int
err
;
if
(
!
PyArg_ParseTuple
(
args
,
"s:unsetenv"
,
&
s1
))
if
(
!
PyArg_ParseTuple
(
args
,
"s:unsetenv"
,
&
s1
))
return
NULL
;
return
NULL
;
unsetenv
(
s1
);
err
=
unsetenv
(
s1
);
if
(
err
)
return
posix_error
();
/* Remove the key from posix_putenv_garbage;
/* Remove the key from posix_putenv_garbage;
* this will cause it to be collected. This has to
* this will cause it to be collected. This has to
...
...
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