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
f347c6eb
Commit
f347c6eb
authored
Dec 20, 2018
by
Zackery Spytz
Committed by
Serhiy Storchaka
Dec 20, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-35504: Fix segfaults and SystemErrors when deleting certain attrs. (GH-11175) (GH-11249)
(cherry picked from commit
842acaab
)
parent
3752bc96
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
38 additions
and
0 deletions
+38
-0
Lib/ctypes/test/test_strings.py
Lib/ctypes/test/test_strings.py
+7
-0
Lib/sqlite3/test/regression.py
Lib/sqlite3/test/regression.py
+4
-0
Lib/test/test_io.py
Lib/test/test_io.py
+5
-0
Misc/NEWS.d/next/Core and Builtins/2018-12-15-14-01-45.bpo-35504.JtKczP.rst
...ore and Builtins/2018-12-15-14-01-45.bpo-35504.JtKczP.rst
+2
-0
Modules/_ctypes/_ctypes.c
Modules/_ctypes/_ctypes.c
+4
-0
Modules/_io/textio.c
Modules/_io/textio.c
+4
-0
Modules/_sqlite/connection.c
Modules/_sqlite/connection.c
+4
-0
Modules/cjkcodecs/multibytecodec.c
Modules/cjkcodecs/multibytecodec.c
+4
-0
Objects/frameobject.c
Objects/frameobject.c
+4
-0
No files found.
Lib/ctypes/test/test_strings.py
View file @
f347c6eb
...
...
@@ -61,6 +61,13 @@ class StringArrayTestCase(unittest.TestCase):
## print BUF.from_param(c_char_p("python"))
## print BUF.from_param(BUF(*"pyth"))
def
test_del_segfault
(
self
):
BUF
=
c_char
*
4
buf
=
BUF
()
with
self
.
assertRaises
(
AttributeError
):
del
buf
.
raw
@
need_symbol
(
'c_wchar'
)
class
WStringArrayTestCase
(
unittest
.
TestCase
):
def
test
(
self
):
...
...
Lib/sqlite3/test/regression.py
View file @
f347c6eb
...
...
@@ -361,6 +361,10 @@ class RegressionTests(unittest.TestCase):
del ref
support.gc_collect()
def CheckDelIsolation_levelSegfault(self):
with self.assertRaises(AttributeError):
del self.con.isolation_level
class UnhashableFunc:
def __hash__(self):
...
...
Lib/test/test_io.py
View file @
f347c6eb
...
...
@@ -2807,6 +2807,11 @@ class CTextIOWrapperTest(TextIOWrapperTest):
t2
.
buddy
=
t1
support
.
gc_collect
()
def
test_del__CHUNK_SIZE_SystemError
(
self
):
t
=
self
.
TextIOWrapper
(
self
.
BytesIO
(),
encoding
=
'ascii'
)
with
self
.
assertRaises
(
AttributeError
):
del
t
.
_CHUNK_SIZE
maybeRaises
=
unittest
.
TestCase
.
assertRaises
...
...
Misc/NEWS.d/next/Core and Builtins/2018-12-15-14-01-45.bpo-35504.JtKczP.rst
0 → 100644
View file @
f347c6eb
Fix segfaults and :exc:`SystemError`\ s when deleting certain attributes.
Patch by Zackery Spytz.
Modules/_ctypes/_ctypes.c
View file @
f347c6eb
...
...
@@ -1216,6 +1216,10 @@ CharArray_set_raw(CDataObject *self, PyObject *value)
#if (PY_VERSION_HEX >= 0x02060000)
Py_buffer
view
=
{
0
};
#endif
if
(
value
==
NULL
)
{
PyErr_SetString
(
PyExc_AttributeError
,
"cannot delete attribute"
);
return
-
1
;
}
if
(
PyBuffer_Check
(
value
))
{
size
=
Py_TYPE
(
value
)
->
tp_as_buffer
->
bf_getreadbuffer
(
value
,
0
,
(
void
*
)
&
ptr
);
if
(
size
<
0
)
...
...
Modules/_io/textio.c
View file @
f347c6eb
...
...
@@ -2593,6 +2593,10 @@ textiowrapper_chunk_size_set(textio *self, PyObject *arg, void *context)
{
Py_ssize_t
n
;
CHECK_ATTACHED_INT
(
self
);
if
(
arg
==
NULL
)
{
PyErr_SetString
(
PyExc_AttributeError
,
"cannot delete attribute"
);
return
-
1
;
}
n
=
PyNumber_AsSsize_t
(
arg
,
PyExc_TypeError
);
if
(
n
==
-
1
&&
PyErr_Occurred
())
return
-
1
;
...
...
Modules/_sqlite/connection.c
View file @
f347c6eb
...
...
@@ -1131,6 +1131,10 @@ static int pysqlite_connection_set_isolation_level(pysqlite_Connection* self, Py
PyObject
*
begin_statement
;
char
*
begin_statement_str
;
if
(
isolation_level
==
NULL
)
{
PyErr_SetString
(
PyExc_AttributeError
,
"cannot delete attribute"
);
return
-
1
;
}
Py_XDECREF
(
self
->
isolation_level
);
if
(
self
->
begin_statement
)
{
...
...
Modules/cjkcodecs/multibytecodec.c
View file @
f347c6eb
...
...
@@ -138,6 +138,10 @@ codecctx_errors_set(MultibyteStatefulCodecContext *self, PyObject *value,
{
PyObject
*
cb
;
if
(
value
==
NULL
)
{
PyErr_SetString
(
PyExc_AttributeError
,
"cannot delete attribute"
);
return
-
1
;
}
if
(
!
PyString_Check
(
value
))
{
PyErr_SetString
(
PyExc_TypeError
,
"errors must be a string"
);
return
-
1
;
...
...
Objects/frameobject.c
View file @
f347c6eb
...
...
@@ -118,6 +118,10 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
int
blockstack_top
=
0
;
/* (ditto) */
unsigned
char
setup_op
=
0
;
/* (ditto) */
if
(
p_new_lineno
==
NULL
)
{
PyErr_SetString
(
PyExc_AttributeError
,
"cannot delete attribute"
);
return
-
1
;
}
/* f_lineno must be an integer. */
if
(
!
PyInt_Check
(
p_new_lineno
))
{
PyErr_SetString
(
PyExc_ValueError
,
...
...
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