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
6fef0f1a
Commit
6fef0f1a
authored
Dec 10, 2018
by
Serhiy Storchaka
Committed by
GitHub
Dec 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-35445: Do not ignore memory errors when create posix.environ. (GH-11049)
parent
72ff7b4c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
37 deletions
+28
-37
Misc/NEWS.d/next/Library/2018-12-09-14-35-49.bpo-35445.LjvtsC.rst
...S.d/next/Library/2018-12-09-14-35-49.bpo-35445.LjvtsC.rst
+1
-0
Modules/posixmodule.c
Modules/posixmodule.c
+27
-37
No files found.
Misc/NEWS.d/next/Library/2018-12-09-14-35-49.bpo-35445.LjvtsC.rst
0 → 100644
View file @
6fef0f1a
Memory errors during creating posix.environ no longer ignored.
Modules/posixmodule.c
View file @
6fef0f1a
...
...
@@ -1356,62 +1356,52 @@ convertenviron(void)
/* _wenviron must be initialized in this way if the program is started
through main() instead of wmain(). */
_wgetenv
(
L""
);
if
(
_wenviron
==
NULL
)
e
=
_wenviron
;
#else
e
=
environ
;
#endif
if
(
e
==
NULL
)
return
d
;
/* This part ignores errors */
for
(
e
=
_wenviron
;
*
e
!=
NULL
;
e
++
)
{
for
(;
*
e
!=
NULL
;
e
++
)
{
PyObject
*
k
;
PyObject
*
v
;
#ifdef MS_WINDOWS
const
wchar_t
*
p
=
wcschr
(
*
e
,
L'='
);
if
(
p
==
NULL
)
continue
;
k
=
PyUnicode_FromWideChar
(
*
e
,
(
Py_ssize_t
)(
p
-*
e
));
if
(
k
==
NULL
)
{
PyErr_Clear
();
continue
;
}
v
=
PyUnicode_FromWideChar
(
p
+
1
,
wcslen
(
p
+
1
));
if
(
v
==
NULL
)
{
PyErr_Clear
();
Py_DECREF
(
k
);
continue
;
}
if
(
PyDict_GetItem
(
d
,
k
)
==
NULL
)
{
if
(
PyDict_SetItem
(
d
,
k
,
v
)
!=
0
)
PyErr_Clear
();
}
Py_DECREF
(
k
);
Py_DECREF
(
v
);
}
#else
if
(
environ
==
NULL
)
return
d
;
/* This part ignores errors */
for
(
e
=
environ
;
*
e
!=
NULL
;
e
++
)
{
PyObject
*
k
;
PyObject
*
v
;
const
char
*
p
=
strchr
(
*
e
,
'='
);
#endif
if
(
p
==
NULL
)
continue
;
#ifdef MS_WINDOWS
k
=
PyUnicode_FromWideChar
(
*
e
,
(
Py_ssize_t
)(
p
-*
e
));
#else
k
=
PyBytes_FromStringAndSize
(
*
e
,
(
int
)(
p
-*
e
));
#endif
if
(
k
==
NULL
)
{
Py
Err_Clear
(
);
continue
;
Py
_DECREF
(
d
);
return
NULL
;
}
#ifdef MS_WINDOWS
v
=
PyUnicode_FromWideChar
(
p
+
1
,
wcslen
(
p
+
1
));
#else
v
=
PyBytes_FromStringAndSize
(
p
+
1
,
strlen
(
p
+
1
));
#endif
if
(
v
==
NULL
)
{
PyErr_Clear
();
Py_DECREF
(
k
);
continue
;
Py_DECREF
(
d
);
return
NULL
;
}
if
(
PyDict_GetItem
(
d
,
k
)
==
NULL
)
{
if
(
PyDict_SetItem
(
d
,
k
,
v
)
!=
0
)
PyErr_Clear
();
if
(
PyDict_GetItemWithError
(
d
,
k
)
==
NULL
)
{
if
(
PyErr_Occurred
()
||
PyDict_SetItem
(
d
,
k
,
v
)
!=
0
)
{
Py_DECREF
(
v
);
Py_DECREF
(
k
);
Py_DECREF
(
d
);
return
NULL
;
}
}
Py_DECREF
(
k
);
Py_DECREF
(
v
);
}
#endif
return
d
;
}
...
...
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