[Python-checkins] cpython (3.5): Issue #23815: Fixed crashes related to directly created instances of types in
serhiy.storchaka
python-checkins at python.org
Sun May 8 13:47:16 EDT 2016
https://hg.python.org/cpython/rev/cd25508c62fc
changeset: 101271:cd25508c62fc
branch: 3.5
parent: 101269:d783cbef73fb
user: Serhiy Storchaka <storchaka at gmail.com>
date: Sun May 08 20:46:22 2016 +0300
summary:
Issue #23815: Fixed crashes related to directly created instances of types in
_tkinter and curses.panel modules.
files:
Lib/test/test_curses.py | 4 ++++
Lib/test/test_tcl.py | 2 ++
Misc/NEWS | 3 +++
Modules/_curses_panel.c | 7 ++++---
Modules/_tkinter.c | 3 +++
5 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py
--- a/Lib/test/test_curses.py
+++ b/Lib/test/test_curses.py
@@ -285,6 +285,10 @@
panel.set_userptr(A())
panel.set_userptr(None)
+ def test_new_curses_panel(self):
+ panel = curses.panel.new_panel(self.stdscr)
+ self.assertRaises(TypeError, type(panel))
+
@unittest.skipUnless(hasattr(curses, 'resizeterm'),
'resizeterm not available')
def test_resize_term(self):
diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py
--- a/Lib/test/test_tcl.py
+++ b/Lib/test/test_tcl.py
@@ -649,6 +649,8 @@
expected = {'a': (1, 2, 3), 'something': 'foo', 'status': ''}
self.assertEqual(splitdict(tcl, arg), expected)
+ def test_new_tcl_obj(self):
+ self.assertRaises(TypeError, _tkinter.Tcl_Obj)
class BigmemTclTest(unittest.TestCase):
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -116,6 +116,9 @@
Library
-------
+- Issue #23815: Fixed crashes related to directly created instances of types in
+ _tkinter and curses.panel modules.
+
- Issue #17765: weakref.ref() no longer silently ignores keyword arguments.
Patch by Georg Brandl.
diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c
--- a/Modules/_curses_panel.c
+++ b/Modules/_curses_panel.c
@@ -506,10 +506,11 @@
d = PyModule_GetDict(m);
/* Initialize object type */
- _curses_panelstate(m)->PyCursesPanel_Type = \
- PyType_FromSpec(&PyCursesPanel_Type_spec);
- if (_curses_panelstate(m)->PyCursesPanel_Type == NULL)
+ v = PyType_FromSpec(&PyCursesPanel_Type_spec);
+ if (v == NULL)
goto fail;
+ ((PyTypeObject *)v)->tp_new = NULL;
+ _curses_panelstate(m)->PyCursesPanel_Type = v;
import_curses();
if (PyErr_Occurred())
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -3551,6 +3551,7 @@
Py_DECREF(m);
return NULL;
}
+ ((PyTypeObject *)o)->tp_new = NULL;
if (PyModule_AddObject(m, "TkappType", o)) {
Py_DECREF(o);
Py_DECREF(m);
@@ -3563,6 +3564,7 @@
Py_DECREF(m);
return NULL;
}
+ ((PyTypeObject *)o)->tp_new = NULL;
if (PyModule_AddObject(m, "TkttType", o)) {
Py_DECREF(o);
Py_DECREF(m);
@@ -3575,6 +3577,7 @@
Py_DECREF(m);
return NULL;
}
+ ((PyTypeObject *)o)->tp_new = NULL;
if (PyModule_AddObject(m, "Tcl_Obj", o)) {
Py_DECREF(o);
Py_DECREF(m);
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list