Kaydet (Commit) 5b0dac12 authored tarafından Nick Coghlan's avatar Nick Coghlan

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

üst c40bc099
...@@ -10,6 +10,8 @@ What's New in Python 3.3.0 Beta 1? ...@@ -10,6 +10,8 @@ What's New in Python 3.3.0 Beta 1?
Core and Builtins Core and Builtins
----------------- -----------------
- Issue #13783: Generator objects now use the identifier APIs internally
- Issue #14874: Restore charmap decoding speed to pre-PEP 393 levels. - Issue #14874: Restore charmap decoding speed to pre-PEP 393 levels.
Patch by Serhiy Storchaka. Patch by Serhiy Storchaka.
......
...@@ -149,13 +149,14 @@ static int ...@@ -149,13 +149,14 @@ static int
gen_close_iter(PyObject *yf) gen_close_iter(PyObject *yf)
{ {
PyObject *retval = NULL; PyObject *retval = NULL;
_Py_IDENTIFIER(close);
if (PyGen_CheckExact(yf)) { if (PyGen_CheckExact(yf)) {
retval = gen_close((PyGenObject *)yf, NULL); retval = gen_close((PyGenObject *)yf, NULL);
if (retval == NULL) if (retval == NULL)
return -1; return -1;
} else { } else {
PyObject *meth = PyObject_GetAttrString(yf, "close"); PyObject *meth = _PyObject_GetAttrId(yf, &PyId_close);
if (meth == NULL) { if (meth == NULL) {
if (!PyErr_ExceptionMatches(PyExc_AttributeError)) if (!PyErr_ExceptionMatches(PyExc_AttributeError))
PyErr_WriteUnraisable(yf); PyErr_WriteUnraisable(yf);
...@@ -295,6 +296,7 @@ gen_throw(PyGenObject *gen, PyObject *args) ...@@ -295,6 +296,7 @@ gen_throw(PyGenObject *gen, PyObject *args)
PyObject *tb = NULL; PyObject *tb = NULL;
PyObject *val = NULL; PyObject *val = NULL;
PyObject *yf = gen_yf(gen); PyObject *yf = gen_yf(gen);
_Py_IDENTIFIER(throw);
if (!PyArg_UnpackTuple(args, "throw", 1, 3, &typ, &val, &tb)) if (!PyArg_UnpackTuple(args, "throw", 1, 3, &typ, &val, &tb))
return NULL; return NULL;
...@@ -316,7 +318,7 @@ gen_throw(PyGenObject *gen, PyObject *args) ...@@ -316,7 +318,7 @@ gen_throw(PyGenObject *gen, PyObject *args)
ret = gen_throw((PyGenObject *)yf, args); ret = gen_throw((PyGenObject *)yf, args);
gen->gi_running = 0; gen->gi_running = 0;
} else { } else {
PyObject *meth = PyObject_GetAttrString(yf, "throw"); PyObject *meth = _PyObject_GetAttrId(yf, &PyId_throw);
if (meth == NULL) { if (meth == NULL) {
if (!PyErr_ExceptionMatches(PyExc_AttributeError)) { if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
Py_DECREF(yf); Py_DECREF(yf);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment