@@ -345,11 +345,10 @@ type_set_qualname(PyTypeObject *type, PyObject *value, void *context)
345345static PyObject *
346346type_module (PyTypeObject * type , void * context )
347347{
348- PyObject * mod ;
349348 char * s ;
350349
351350 if (type -> tp_flags & Py_TPFLAGS_HEAPTYPE ) {
352- mod = _PyDict_GetItemId (type -> tp_dict , & PyId___module__ );
351+ PyObject * mod = _PyDict_GetItemId (type -> tp_dict , & PyId___module__ );
353352 if (!mod ) {
354353 PyErr_Format (PyExc_AttributeError , "__module__" );
355354 return 0 ;
@@ -358,11 +357,14 @@ type_module(PyTypeObject *type, void *context)
358357 return mod ;
359358 }
360359 else {
360+ PyObject * name ;
361361 s = strrchr (type -> tp_name , '.' );
362362 if (s != NULL )
363363 return PyUnicode_FromStringAndSize (
364364 type -> tp_name , (Py_ssize_t )(s - type -> tp_name ));
365- return PyUnicode_FromString ("builtins" );
365+ name = _PyUnicode_FromId (& _PyId_builtins );
366+ Py_XINCREF (name );
367+ return name ;
366368 }
367369}
368370
@@ -712,7 +714,7 @@ type_repr(PyTypeObject *type)
712714 return NULL ;
713715 }
714716
715- if (mod != NULL && PyUnicode_CompareWithASCIIString (mod , "builtins" ))
717+ if (mod != NULL && _PyUnicode_CompareWithId (mod , & _PyId_builtins ))
716718 rtn = PyUnicode_FromFormat ("<class '%U.%U'>" , mod , name );
717719 else
718720 rtn = PyUnicode_FromFormat ("<class '%s'>" , type -> tp_name );
@@ -2143,7 +2145,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
21432145 if (!valid_identifier (tmp ))
21442146 goto error ;
21452147 assert (PyUnicode_Check (tmp ));
2146- if (PyUnicode_CompareWithASCIIString (tmp , "__dict__" ) == 0 ) {
2148+ if (_PyUnicode_CompareWithId (tmp , & PyId___dict__ ) == 0 ) {
21472149 if (!may_add_dict || add_dict ) {
21482150 PyErr_SetString (PyExc_TypeError ,
21492151 "__dict__ slot disallowed: "
@@ -2174,7 +2176,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
21742176 for (i = j = 0 ; i < nslots ; i ++ ) {
21752177 tmp = PyTuple_GET_ITEM (slots , i );
21762178 if ((add_dict &&
2177- PyUnicode_CompareWithASCIIString (tmp , "__dict__" ) == 0 ) ||
2179+ _PyUnicode_CompareWithId (tmp , & PyId___dict__ ) == 0 ) ||
21782180 (add_weak &&
21792181 PyUnicode_CompareWithASCIIString (tmp , "__weakref__" ) == 0 ))
21802182 continue ;
@@ -3183,7 +3185,7 @@ object_repr(PyObject *self)
31833185 Py_XDECREF (mod );
31843186 return NULL ;
31853187 }
3186- if (mod != NULL && PyUnicode_CompareWithASCIIString (mod , "builtins" ))
3188+ if (mod != NULL && _PyUnicode_CompareWithId (mod , & _PyId_builtins ))
31873189 rtn = PyUnicode_FromFormat ("<%U.%U object at %p>" , mod , name , self );
31883190 else
31893191 rtn = PyUnicode_FromFormat ("<%s object at %p>" ,
@@ -6336,8 +6338,8 @@ super_getattro(PyObject *self, PyObject *name)
63366338 /* We want __class__ to return the class of the super object
63376339 (i.e. super, or a subclass), not the class of su->obj. */
63386340 skip = (PyUnicode_Check (name ) &&
6339- PyUnicode_GET_LENGTH (name ) == 9 &&
6340- PyUnicode_CompareWithASCIIString (name , "__class__" ) == 0 );
6341+ PyUnicode_GET_LENGTH (name ) == 9 &&
6342+ _PyUnicode_CompareWithId (name , & PyId___class__ ) == 0 );
63416343 }
63426344
63436345 if (!skip ) {
@@ -6543,8 +6545,7 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds)
65436545 for (i = 0 ; i < n ; i ++ ) {
65446546 PyObject * name = PyTuple_GET_ITEM (co -> co_freevars , i );
65456547 assert (PyUnicode_Check (name ));
6546- if (!PyUnicode_CompareWithASCIIString (name ,
6547- "__class__" )) {
6548+ if (!_PyUnicode_CompareWithId (name , & PyId___class__ )) {
65486549 Py_ssize_t index = co -> co_nlocals +
65496550 PyTuple_GET_SIZE (co -> co_cellvars ) + i ;
65506551 PyObject * cell = f -> f_localsplus [index ];
0 commit comments