summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-05-08 17:46:22 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-05-08 17:46:22 (GMT)
commite3f1b0911e02f5108b90b9b25417a448a423da40 (patch)
treea9f0a153bfdbe33f242c3dcbcb25f6b2d31afe8e
parent4c35964b764540988bfb342bffc7c4b1cb674031 (diff)
downloadcpython-e3f1b0911e02f5108b90b9b25417a448a423da40.zip
cpython-e3f1b0911e02f5108b90b9b25417a448a423da40.tar.gz
cpython-e3f1b0911e02f5108b90b9b25417a448a423da40.tar.bz2
Issue #23815: Fixed crashes related to directly created instances of types in
_tkinter and curses.panel modules.
-rw-r--r--Lib/test/test_curses.py4
-rw-r--r--Lib/test/test_tcl.py2
-rw-r--r--Misc/NEWS3
-rw-r--r--Modules/_curses_panel.c7
-rw-r--r--Modules/_tkinter.c3
5 files changed, 16 insertions, 3 deletions
diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py
index 2747041..222105e 100644
--- a/Lib/test/test_curses.py
+++ b/Lib/test/test_curses.py
@@ -285,6 +285,10 @@ class TestCurses(unittest.TestCase):
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
index 25f6ede..8ffd185 100644
--- a/Lib/test/test_tcl.py
+++ b/Lib/test/test_tcl.py
@@ -649,6 +649,8 @@ class TclTest(unittest.TestCase):
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
index f31b172..870f5a3 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -116,6 +116,9 @@ Core and Builtins
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
index 759b731..c77e614 100644
--- a/Modules/_curses_panel.c
+++ b/Modules/_curses_panel.c
@@ -506,10 +506,11 @@ PyInit__curses_panel(void)
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
index 41ad5f9..cf56fa8 100644
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -3551,6 +3551,7 @@ PyInit__tkinter(void)
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 @@ PyInit__tkinter(void)
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 @@ PyInit__tkinter(void)
Py_DECREF(m);
return NULL;
}
+ ((PyTypeObject *)o)->tp_new = NULL;
if (PyModule_AddObject(m, "Tcl_Obj", o)) {
Py_DECREF(o);
Py_DECREF(m);