@@ -101,8 +101,6 @@ bytes(cdata)
101
101
#ifndef Py_BUILD_CORE_BUILTIN
102
102
# define Py_BUILD_CORE_MODULE 1
103
103
#endif
104
- #define NEEDS_PY_IDENTIFIER
105
-
106
104
#define PY_SSIZE_T_CLEAN
107
105
108
106
#include "Python.h"
@@ -498,8 +496,6 @@ StructUnionType_new(PyTypeObject *type, PyObject *args, PyObject *kwds, int isSt
498
496
PyTypeObject * result ;
499
497
PyObject * fields ;
500
498
StgDictObject * dict ;
501
- _Py_IDENTIFIER (_abstract_ );
502
- _Py_IDENTIFIER (_fields_ );
503
499
504
500
/* create the new instance (which is a class,
505
501
since we are a metatype!) */
@@ -508,7 +504,7 @@ StructUnionType_new(PyTypeObject *type, PyObject *args, PyObject *kwds, int isSt
508
504
return NULL ;
509
505
510
506
/* keep this for bw compatibility */
511
- int r = _PyDict_ContainsId (result -> tp_dict , & PyId__abstract_ );
507
+ int r = PyDict_Contains (result -> tp_dict , & _Py_ID ( _abstract_ ) );
512
508
if (r > 0 )
513
509
return (PyObject * )result ;
514
510
if (r < 0 ) {
@@ -540,9 +536,9 @@ StructUnionType_new(PyTypeObject *type, PyObject *args, PyObject *kwds, int isSt
540
536
541
537
dict -> paramfunc = StructUnionType_paramfunc ;
542
538
543
- fields = _PyDict_GetItemIdWithError ((PyObject * )dict , & PyId__fields_ );
539
+ fields = PyDict_GetItemWithError ((PyObject * )dict , & _Py_ID ( _fields_ ) );
544
540
if (fields ) {
545
- if (_PyObject_SetAttrId ((PyObject * )result , & PyId__fields_ , fields ) < 0 ) {
541
+ if (PyObject_SetAttr ((PyObject * )result , & _Py_ID ( _fields_ ) , fields ) < 0 ) {
546
542
Py_DECREF (result );
547
543
return NULL ;
548
544
}
@@ -797,7 +793,6 @@ PyDoc_STRVAR(from_param_doc,
797
793
static PyObject *
798
794
CDataType_from_param (PyObject * type , PyObject * value )
799
795
{
800
- _Py_IDENTIFIER (_as_parameter_ );
801
796
PyObject * as_parameter ;
802
797
int res = PyObject_IsInstance (value , type );
803
798
if (res == -1 )
@@ -831,7 +826,7 @@ CDataType_from_param(PyObject *type, PyObject *value)
831
826
return NULL ;
832
827
}
833
828
834
- if (_PyObject_LookupAttrId (value , & PyId__as_parameter_ , & as_parameter ) < 0 ) {
829
+ if (_PyObject_LookupAttr (value , & _Py_ID ( _as_parameter_ ) , & as_parameter ) < 0 ) {
835
830
return NULL ;
836
831
}
837
832
if (as_parameter ) {
@@ -1068,7 +1063,7 @@ PyCPointerType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
1068
1063
StgDictObject * stgdict ;
1069
1064
PyObject * proto ;
1070
1065
PyObject * typedict ;
1071
- _Py_IDENTIFIER ( _type_ );
1066
+
1072
1067
1073
1068
typedict = PyTuple_GetItem (args , 2 );
1074
1069
if (!typedict )
@@ -1088,7 +1083,7 @@ PyCPointerType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
1088
1083
stgdict -> paramfunc = PyCPointerType_paramfunc ;
1089
1084
stgdict -> flags |= TYPEFLAG_ISPOINTER ;
1090
1085
1091
- proto = _PyDict_GetItemIdWithError (typedict , & PyId__type_ ); /* Borrowed ref */
1086
+ proto = PyDict_GetItemWithError (typedict , & _Py_ID ( _type_ ) ); /* Borrowed ref */
1092
1087
if (proto ) {
1093
1088
StgDictObject * itemdict ;
1094
1089
const char * current_format ;
@@ -1146,7 +1141,7 @@ static PyObject *
1146
1141
PyCPointerType_set_type (PyTypeObject * self , PyObject * type )
1147
1142
{
1148
1143
StgDictObject * dict ;
1149
- _Py_IDENTIFIER ( _type_ );
1144
+
1150
1145
1151
1146
dict = PyType_stgdict ((PyObject * )self );
1152
1147
if (!dict ) {
@@ -1158,7 +1153,7 @@ PyCPointerType_set_type(PyTypeObject *self, PyObject *type)
1158
1153
if (-1 == PyCPointerType_SetProto (dict , type ))
1159
1154
return NULL ;
1160
1155
1161
- if (-1 == _PyDict_SetItemId ((PyObject * )dict , & PyId__type_ , type ))
1156
+ if (-1 == PyDict_SetItem ((PyObject * )dict , & _Py_ID ( _type_ ) , type ))
1162
1157
return NULL ;
1163
1158
1164
1159
Py_RETURN_NONE ;
@@ -1461,8 +1456,6 @@ PyCArrayType_paramfunc(CDataObject *self)
1461
1456
static PyObject *
1462
1457
PyCArrayType_new (PyTypeObject * type , PyObject * args , PyObject * kwds )
1463
1458
{
1464
- _Py_IDENTIFIER (_length_ );
1465
- _Py_IDENTIFIER (_type_ );
1466
1459
PyTypeObject * result ;
1467
1460
StgDictObject * stgdict ;
1468
1461
StgDictObject * itemdict ;
@@ -1481,7 +1474,7 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
1481
1474
stgdict = NULL ;
1482
1475
type_attr = NULL ;
1483
1476
1484
- if (_PyObject_LookupAttrId ((PyObject * )result , & PyId__length_ , & length_attr ) < 0 ) {
1477
+ if (_PyObject_LookupAttr ((PyObject * )result , & _Py_ID ( _length_ ) , & length_attr ) < 0 ) {
1485
1478
goto error ;
1486
1479
}
1487
1480
if (!length_attr ) {
@@ -1514,7 +1507,7 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
1514
1507
goto error ;
1515
1508
}
1516
1509
1517
- if (_PyObject_LookupAttrId ((PyObject * )result , & PyId__type_ , & type_attr ) < 0 ) {
1510
+ if (_PyObject_LookupAttr ((PyObject * )result , & _Py_ID ( _type_ ) , & type_attr ) < 0 ) {
1518
1511
goto error ;
1519
1512
}
1520
1513
if (!type_attr ) {
@@ -1659,7 +1652,6 @@ static const char SIMPLE_TYPE_CHARS[] = "cbBhHiIlLdfuzZqQPXOv?g";
1659
1652
static PyObject *
1660
1653
c_wchar_p_from_param (PyObject * type , PyObject * value )
1661
1654
{
1662
- _Py_IDENTIFIER (_as_parameter_ );
1663
1655
PyObject * as_parameter ;
1664
1656
int res ;
1665
1657
if (value == Py_None ) {
@@ -1709,7 +1701,7 @@ c_wchar_p_from_param(PyObject *type, PyObject *value)
1709
1701
}
1710
1702
}
1711
1703
1712
- if (_PyObject_LookupAttrId (value , & PyId__as_parameter_ , & as_parameter ) < 0 ) {
1704
+ if (_PyObject_LookupAttr (value , & _Py_ID ( _as_parameter_ ) , & as_parameter ) < 0 ) {
1713
1705
return NULL ;
1714
1706
}
1715
1707
if (as_parameter ) {
@@ -1726,7 +1718,6 @@ c_wchar_p_from_param(PyObject *type, PyObject *value)
1726
1718
static PyObject *
1727
1719
c_char_p_from_param (PyObject * type , PyObject * value )
1728
1720
{
1729
- _Py_IDENTIFIER (_as_parameter_ );
1730
1721
PyObject * as_parameter ;
1731
1722
int res ;
1732
1723
if (value == Py_None ) {
@@ -1776,7 +1767,7 @@ c_char_p_from_param(PyObject *type, PyObject *value)
1776
1767
}
1777
1768
}
1778
1769
1779
- if (_PyObject_LookupAttrId (value , & PyId__as_parameter_ , & as_parameter ) < 0 ) {
1770
+ if (_PyObject_LookupAttr (value , & _Py_ID ( _as_parameter_ ) , & as_parameter ) < 0 ) {
1780
1771
return NULL ;
1781
1772
}
1782
1773
if (as_parameter ) {
@@ -1793,7 +1784,6 @@ c_char_p_from_param(PyObject *type, PyObject *value)
1793
1784
static PyObject *
1794
1785
c_void_p_from_param (PyObject * type , PyObject * value )
1795
1786
{
1796
- _Py_IDENTIFIER (_as_parameter_ );
1797
1787
StgDictObject * stgd ;
1798
1788
PyObject * as_parameter ;
1799
1789
int res ;
@@ -1915,7 +1905,7 @@ c_void_p_from_param(PyObject *type, PyObject *value)
1915
1905
}
1916
1906
}
1917
1907
1918
- if (_PyObject_LookupAttrId (value , & PyId__as_parameter_ , & as_parameter ) < 0 ) {
1908
+ if (_PyObject_LookupAttr (value , & _Py_ID ( _as_parameter_ ) , & as_parameter ) < 0 ) {
1919
1909
return NULL ;
1920
1910
}
1921
1911
if (as_parameter ) {
@@ -2038,7 +2028,6 @@ PyCSimpleType_paramfunc(CDataObject *self)
2038
2028
static PyObject *
2039
2029
PyCSimpleType_new (PyTypeObject * type , PyObject * args , PyObject * kwds )
2040
2030
{
2041
- _Py_IDENTIFIER (_type_ );
2042
2031
PyTypeObject * result ;
2043
2032
StgDictObject * stgdict ;
2044
2033
PyObject * proto ;
@@ -2053,7 +2042,7 @@ PyCSimpleType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
2053
2042
if (result == NULL )
2054
2043
return NULL ;
2055
2044
2056
- if (_PyObject_LookupAttrId ((PyObject * )result , & PyId__type_ , & proto ) < 0 ) {
2045
+ if (_PyObject_LookupAttr ((PyObject * )result , & _Py_ID ( _type_ ) , & proto ) < 0 ) {
2057
2046
return NULL ;
2058
2047
}
2059
2048
if (!proto ) {
@@ -2223,7 +2212,6 @@ PyCSimpleType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
2223
2212
static PyObject *
2224
2213
PyCSimpleType_from_param (PyObject * type , PyObject * value )
2225
2214
{
2226
- _Py_IDENTIFIER (_as_parameter_ );
2227
2215
StgDictObject * dict ;
2228
2216
const char * fmt ;
2229
2217
PyCArgObject * parg ;
@@ -2267,7 +2255,7 @@ PyCSimpleType_from_param(PyObject *type, PyObject *value)
2267
2255
PyErr_Clear ();
2268
2256
Py_DECREF (parg );
2269
2257
2270
- if (_PyObject_LookupAttrId (value , & PyId__as_parameter_ , & as_parameter ) < 0 ) {
2258
+ if (_PyObject_LookupAttr (value , & _Py_ID ( _as_parameter_ ) , & as_parameter ) < 0 ) {
2271
2259
return NULL ;
2272
2260
}
2273
2261
if (as_parameter ) {
@@ -2344,7 +2332,6 @@ PyTypeObject PyCSimpleType_Type = {
2344
2332
static PyObject *
2345
2333
converters_from_argtypes (PyObject * ob )
2346
2334
{
2347
- _Py_IDENTIFIER (from_param );
2348
2335
PyObject * converters ;
2349
2336
Py_ssize_t i ;
2350
2337
@@ -2424,7 +2411,7 @@ converters_from_argtypes(PyObject *ob)
2424
2411
}
2425
2412
*/
2426
2413
2427
- if (_PyObject_LookupAttrId (tp , & PyId_from_param , & cnv ) <= 0 ) {
2414
+ if (_PyObject_LookupAttr (tp , & _Py_ID ( from_param ) , & cnv ) <= 0 ) {
2428
2415
Py_DECREF (converters );
2429
2416
Py_DECREF (ob );
2430
2417
if (!PyErr_Occurred ()) {
@@ -2445,10 +2432,6 @@ make_funcptrtype_dict(StgDictObject *stgdict)
2445
2432
{
2446
2433
PyObject * ob ;
2447
2434
PyObject * converters = NULL ;
2448
- _Py_IDENTIFIER (_flags_ );
2449
- _Py_IDENTIFIER (_argtypes_ );
2450
- _Py_IDENTIFIER (_restype_ );
2451
- _Py_IDENTIFIER (_check_retval_ );
2452
2435
2453
2436
stgdict -> align = _ctypes_get_fielddesc ("P" )-> pffi_type -> alignment ;
2454
2437
stgdict -> length = 1 ;
@@ -2457,7 +2440,7 @@ make_funcptrtype_dict(StgDictObject *stgdict)
2457
2440
stgdict -> getfunc = NULL ;
2458
2441
stgdict -> ffi_type_pointer = ffi_type_pointer ;
2459
2442
2460
- ob = _PyDict_GetItemIdWithError ((PyObject * )stgdict , & PyId__flags_ );
2443
+ ob = PyDict_GetItemWithError ((PyObject * )stgdict , & _Py_ID ( _flags_ ) );
2461
2444
if (!ob || !PyLong_Check (ob )) {
2462
2445
if (!PyErr_Occurred ()) {
2463
2446
PyErr_SetString (PyExc_TypeError ,
@@ -2468,7 +2451,7 @@ make_funcptrtype_dict(StgDictObject *stgdict)
2468
2451
stgdict -> flags = PyLong_AsUnsignedLongMask (ob ) | TYPEFLAG_ISPOINTER ;
2469
2452
2470
2453
/* _argtypes_ is optional... */
2471
- ob = _PyDict_GetItemIdWithError ((PyObject * )stgdict , & PyId__argtypes_ );
2454
+ ob = PyDict_GetItemWithError ((PyObject * )stgdict , & _Py_ID ( _argtypes_ ) );
2472
2455
if (ob ) {
2473
2456
converters = converters_from_argtypes (ob );
2474
2457
if (!converters )
@@ -2481,7 +2464,7 @@ make_funcptrtype_dict(StgDictObject *stgdict)
2481
2464
return -1 ;
2482
2465
}
2483
2466
2484
- ob = _PyDict_GetItemIdWithError ((PyObject * )stgdict , & PyId__restype_ );
2467
+ ob = PyDict_GetItemWithError ((PyObject * )stgdict , & _Py_ID ( _restype_ ) );
2485
2468
if (ob ) {
2486
2469
if (ob != Py_None && !PyType_stgdict (ob ) && !PyCallable_Check (ob )) {
2487
2470
PyErr_SetString (PyExc_TypeError ,
@@ -2490,7 +2473,7 @@ make_funcptrtype_dict(StgDictObject *stgdict)
2490
2473
}
2491
2474
Py_INCREF (ob );
2492
2475
stgdict -> restype = ob ;
2493
- if (_PyObject_LookupAttrId (ob , & PyId__check_retval_ ,
2476
+ if (_PyObject_LookupAttr (ob , & _Py_ID ( _check_retval_ ) ,
2494
2477
& stgdict -> checker ) < 0 )
2495
2478
{
2496
2479
return -1 ;
@@ -3254,7 +3237,6 @@ PyCFuncPtr_get_errcheck(PyCFuncPtrObject *self, void *Py_UNUSED(ignored))
3254
3237
static int
3255
3238
PyCFuncPtr_set_restype (PyCFuncPtrObject * self , PyObject * ob , void * Py_UNUSED (ignored ))
3256
3239
{
3257
- _Py_IDENTIFIER (_check_retval_ );
3258
3240
PyObject * checker , * oldchecker ;
3259
3241
if (ob == NULL ) {
3260
3242
oldchecker = self -> checker ;
@@ -3268,7 +3250,7 @@ PyCFuncPtr_set_restype(PyCFuncPtrObject *self, PyObject *ob, void *Py_UNUSED(ign
3268
3250
"restype must be a type, a callable, or None" );
3269
3251
return -1 ;
3270
3252
}
3271
- if (_PyObject_LookupAttrId (ob , & PyId__check_retval_ , & checker ) < 0 ) {
3253
+ if (_PyObject_LookupAttr (ob , & _Py_ID ( _check_retval_ ) , & checker ) < 0 ) {
3272
3254
return -1 ;
3273
3255
}
3274
3256
oldchecker = self -> checker ;
@@ -4062,10 +4044,9 @@ _build_result(PyObject *result, PyObject *callargs,
4062
4044
PyTuple_SET_ITEM (tup , index , v );
4063
4045
index ++ ;
4064
4046
} else if (bit & outmask ) {
4065
- _Py_IDENTIFIER (__ctypes_from_outparam__ );
4066
4047
4067
4048
v = PyTuple_GET_ITEM (callargs , i );
4068
- v = _PyObject_CallMethodIdNoArgs (v , & PyId___ctypes_from_outparam__ );
4049
+ v = PyObject_CallMethodNoArgs (v , & _Py_ID ( __ctypes_from_outparam__ ) );
4069
4050
if (v == NULL || numretvals == 1 ) {
4070
4051
Py_DECREF (callargs );
4071
4052
return v ;
@@ -4348,7 +4329,6 @@ _init_pos_args(PyObject *self, PyTypeObject *type,
4348
4329
StgDictObject * dict ;
4349
4330
PyObject * fields ;
4350
4331
Py_ssize_t i ;
4351
- _Py_IDENTIFIER (_fields_ );
4352
4332
4353
4333
if (PyType_stgdict ((PyObject * )type -> tp_base )) {
4354
4334
index = _init_pos_args (self , type -> tp_base ,
@@ -4359,7 +4339,7 @@ _init_pos_args(PyObject *self, PyTypeObject *type,
4359
4339
}
4360
4340
4361
4341
dict = PyType_stgdict ((PyObject * )type );
4362
- fields = _PyDict_GetItemIdWithError ((PyObject * )dict , & PyId__fields_ );
4342
+ fields = PyDict_GetItemWithError ((PyObject * )dict , & _Py_ID ( _fields_ ) );
4363
4343
if (fields == NULL ) {
4364
4344
if (PyErr_Occurred ()) {
4365
4345
return -1 ;
0 commit comments