Commits

Nick Coghlan committed 438b861

Issue #13783: PEP 380 cleanup part 2, using the new identifier APIs in the generator implementation

Comments (0)

Files changed (2)

 Core and Builtins
 -----------------
 
+- Issue #13783: Generator objects now use the identifier APIs internally
+
 - Issue #14874: Restore charmap decoding speed to pre-PEP 393 levels.
   Patch by Serhiy Storchaka.
 

Objects/genobject.c

 gen_close_iter(PyObject *yf)
 {
     PyObject *retval = NULL;
+    _Py_IDENTIFIER(close);
 
     if (PyGen_CheckExact(yf)) {
         retval = gen_close((PyGenObject *)yf, NULL);
         if (retval == NULL)
             return -1;
     } else {
-        PyObject *meth = PyObject_GetAttrString(yf, "close");
+        PyObject *meth = _PyObject_GetAttrId(yf, &PyId_close);
         if (meth == NULL) {
             if (!PyErr_ExceptionMatches(PyExc_AttributeError))
                 PyErr_WriteUnraisable(yf);
     PyObject *tb = NULL;
     PyObject *val = NULL;
     PyObject *yf = gen_yf(gen);
+    _Py_IDENTIFIER(throw);
 
     if (!PyArg_UnpackTuple(args, "throw", 1, 3, &typ, &val, &tb))
         return NULL;
             ret = gen_throw((PyGenObject *)yf, args);
             gen->gi_running = 0;
         } else {
-            PyObject *meth = PyObject_GetAttrString(yf, "throw");
+            PyObject *meth = _PyObject_GetAttrId(yf, &PyId_throw);
             if (meth == NULL) {
                 if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
                     Py_DECREF(yf);