Skip to content

Commit 2cc4dd1

Browse files
author
Erlend E. Aasland
committed
Adapt _curses_panel and tkinter workarounds/tests
1 parent 69b19bc commit 2cc4dd1

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

Lib/test/test_curses.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import tempfile
77
import unittest
88

9-
from test.support import requires, verbose, SaveSignals
9+
from test.support import requires, verbose, SaveSignals, cpython_only
1010
from test.support.import_helper import import_module
1111

1212
# Optionally test curses module. This currently requires that the
@@ -1046,6 +1046,7 @@ def __del__(self):
10461046
panel.set_userptr(A())
10471047
panel.set_userptr(None)
10481048

1049+
@cpython_only
10491050
@requires_curses_func('panel')
10501051
def test_new_curses_panel(self):
10511052
w = curses.newwin(10, 10)

Lib/test/test_tcl.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,8 +736,11 @@ def check(value):
736736
check('{\n')
737737
check('}\n')
738738

739+
@support.cpython_only
739740
def test_new_tcl_obj(self):
740741
self.assertRaises(TypeError, _tkinter.Tcl_Obj)
742+
self.assertRaises(TypeError, _tkinter.TkttType)
743+
self.assertRaises(TypeError, _tkinter.TkappType)
741744

742745
class BigmemTclTest(unittest.TestCase):
743746

Lib/test/test_unicodedata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def test_east_asian_width_9_0_changes(self):
226226

227227
class UnicodeMiscTest(UnicodeDatabaseTest):
228228

229-
@support.cpython_only
229+
@cpython_only
230230
def test_uninitialised_new(self):
231231
# Prevent heap types from being created uninitialised (bpo-43916)
232232
self.assertRaises(TypeError, unicodedata.UCD)

Modules/_curses_panel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ static PyMethodDef PyCursesPanel_Methods[] = {
514514
static PyType_Slot PyCursesPanel_Type_slots[] = {
515515
{Py_tp_dealloc, PyCursesPanel_Dealloc},
516516
{Py_tp_methods, PyCursesPanel_Methods},
517+
{Py_tp_new, _PyType_DisabledNew},
517518
{0, 0},
518519
};
519520

@@ -656,7 +657,6 @@ _curses_panel_exec(PyObject *mod)
656657
if (state->PyCursesPanel_Type == NULL) {
657658
return -1;
658659
}
659-
((PyTypeObject *)state->PyCursesPanel_Type)->tp_new = NULL;
660660

661661
if (PyModule_AddType(mod, state->PyCursesPanel_Type) < 0) {
662662
return -1;

Modules/_tkinter.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,7 @@ static PyType_Slot PyTclObject_Type_slots[] = {
995995
{Py_tp_getattro, PyObject_GenericGetAttr},
996996
{Py_tp_richcompare, PyTclObject_richcompare},
997997
{Py_tp_getset, PyTclObject_getsetlist},
998+
{Py_tp_new, _PyType_DisabledNew},
998999
{0, 0}
9991000
};
10001001

@@ -3287,6 +3288,7 @@ static PyType_Slot Tktt_Type_slots[] = {
32873288
{Py_tp_dealloc, Tktt_Dealloc},
32883289
{Py_tp_repr, Tktt_Repr},
32893290
{Py_tp_methods, Tktt_methods},
3291+
{Py_tp_new, _PyType_DisabledNew},
32903292
{0, 0}
32913293
};
32923294

@@ -3341,6 +3343,7 @@ static PyMethodDef Tkapp_methods[] =
33413343
static PyType_Slot Tkapp_Type_slots[] = {
33423344
{Py_tp_dealloc, Tkapp_Dealloc},
33433345
{Py_tp_methods, Tkapp_methods},
3346+
{Py_tp_new, _PyType_DisabledNew},
33443347
{0, 0}
33453348
};
33463349

@@ -3537,7 +3540,6 @@ PyInit__tkinter(void)
35373540
Py_DECREF(m);
35383541
return NULL;
35393542
}
3540-
((PyTypeObject *)o)->tp_new = NULL;
35413543
if (PyModule_AddObject(m, "TkappType", o)) {
35423544
Py_DECREF(o);
35433545
Py_DECREF(m);
@@ -3550,7 +3552,6 @@ PyInit__tkinter(void)
35503552
Py_DECREF(m);
35513553
return NULL;
35523554
}
3553-
((PyTypeObject *)o)->tp_new = NULL;
35543555
if (PyModule_AddObject(m, "TkttType", o)) {
35553556
Py_DECREF(o);
35563557
Py_DECREF(m);
@@ -3563,7 +3564,6 @@ PyInit__tkinter(void)
35633564
Py_DECREF(m);
35643565
return NULL;
35653566
}
3566-
((PyTypeObject *)o)->tp_new = NULL;
35673567
if (PyModule_AddObject(m, "Tcl_Obj", o)) {
35683568
Py_DECREF(o);
35693569
Py_DECREF(m);

0 commit comments

Comments
 (0)