@@ -1475,39 +1475,34 @@ static int init_methodtype(void)
1475
1475
1476
1476
******************************************************/
1477
1477
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 ;
1488
1478
1489
1479
static PyTypeObject wrap_PyDictKeys_Type ;
1490
1480
1491
- PyObject *
1481
+ static PyObject *
1492
1482
dictview_new (PyTypeObject * type , PyObject * args , PyObject * kwds )
1493
1483
{
1494
- dictviewobject * inst ;
1484
+ PyObject * inst ;
1495
1485
PyObject * dict ;
1496
- if (PyTuple_Size (args ) != 1 )
1486
+ Py_ssize_t size = PyTuple_Size (args );
1487
+
1488
+ if (size == -1 ) {
1497
1489
return NULL ;
1490
+ }
1491
+ if (size != 1 ) {
1492
+ PyErr_SetString (PyExc_ValueError , "args must contain exactly one argument" );
1493
+ return NULL ;
1494
+ }
1498
1495
dict = PyTuple_GetItem (args , 0 );
1499
- inst = PyObject_GC_New (dictviewobject , type -> tp_base );
1500
- if (inst == NULL )
1496
+ if (dict == NULL )
1501
1497
return NULL ;
1502
- Py_INCREF (dict );
1503
- inst -> dv_dict = (PyDictObject * )dict ;
1498
+ inst = _PyDictView_New (dict , type -> tp_base );
1504
1499
if (inst != NULL )
1505
1500
Py_TYPE (inst ) = type ;
1506
1501
return (PyObject * )inst ;
1507
1502
}
1508
1503
1509
1504
static PyObject *
1510
- dictkeysview_reduce (dictviewobject * di )
1505
+ dictkeysview_reduce (_PyDictViewObject * di )
1511
1506
{
1512
1507
PyObject * tup ;
1513
1508
@@ -1522,7 +1517,7 @@ dictkeysview_reduce(dictviewobject *di)
1522
1517
static PyTypeObject wrap_PyDictValues_Type ;
1523
1518
1524
1519
static PyObject *
1525
- dictvaluesview_reduce (dictviewobject * di )
1520
+ dictvaluesview_reduce (_PyDictViewObject * di )
1526
1521
{
1527
1522
PyObject * tup ;
1528
1523
@@ -1537,7 +1532,7 @@ dictvaluesview_reduce(dictviewobject *di)
1537
1532
static PyTypeObject wrap_PyDictItems_Type ;
1538
1533
1539
1534
static PyObject *
1540
- dictitemsview_reduce (dictviewobject * di )
1535
+ dictitemsview_reduce (_PyDictViewObject * di )
1541
1536
{
1542
1537
PyObject * tup ;
1543
1538
0 commit comments