@@ -1475,39 +1475,34 @@ static int init_methodtype(void)
14751475
14761476 ******************************************************/
14771477
1478- /*
1479- * unfortunately we have to copy here.
1480- * XXX automate checking such situations.
1481- */
1482-
1483-
1484- typedef struct {
1485- PyObject_HEAD
1486- PyDictObject * dv_dict ;
1487- } dictviewobject ;
14881478
14891479static PyTypeObject wrap_PyDictKeys_Type ;
14901480
1491- PyObject *
1481+ static PyObject *
14921482dictview_new (PyTypeObject * type , PyObject * args , PyObject * kwds )
14931483{
1494- dictviewobject * inst ;
1484+ PyObject * inst ;
14951485 PyObject * dict ;
1496- if (PyTuple_Size (args ) != 1 )
1486+ Py_ssize_t size = PyTuple_Size (args );
1487+
1488+ if (size == -1 ) {
14971489 return NULL ;
1490+ }
1491+ if (size != 1 ) {
1492+ PyErr_SetString (PyExc_ValueError , "args must contain exactly one argument" );
1493+ return NULL ;
1494+ }
14981495 dict = PyTuple_GetItem (args , 0 );
1499- inst = PyObject_GC_New (dictviewobject , type -> tp_base );
1500- if (inst == NULL )
1496+ if (dict == NULL )
15011497 return NULL ;
1502- Py_INCREF (dict );
1503- inst -> dv_dict = (PyDictObject * )dict ;
1498+ inst = _PyDictView_New (dict , type -> tp_base );
15041499 if (inst != NULL )
15051500 Py_TYPE (inst ) = type ;
15061501 return (PyObject * )inst ;
15071502}
15081503
15091504static PyObject *
1510- dictkeysview_reduce (dictviewobject * di )
1505+ dictkeysview_reduce (_PyDictViewObject * di )
15111506{
15121507 PyObject * tup ;
15131508
@@ -1522,7 +1517,7 @@ dictkeysview_reduce(dictviewobject *di)
15221517static PyTypeObject wrap_PyDictValues_Type ;
15231518
15241519static PyObject *
1525- dictvaluesview_reduce (dictviewobject * di )
1520+ dictvaluesview_reduce (_PyDictViewObject * di )
15261521{
15271522 PyObject * tup ;
15281523
@@ -1537,7 +1532,7 @@ dictvaluesview_reduce(dictviewobject *di)
15371532static PyTypeObject wrap_PyDictItems_Type ;
15381533
15391534static PyObject *
1540- dictitemsview_reduce (dictviewobject * di )
1535+ dictitemsview_reduce (_PyDictViewObject * di )
15411536{
15421537 PyObject * tup ;
15431538
0 commit comments