comparison Python/sysmodule.c @ 72926:db4aa878cea2

Port SetAttrString/HasAttrString to SetAttrId/GetAttrId.
author Martin v. Löwis <martin@v.loewis.de>
date Fri, 14 Oct 2011 15:16:45 +0200
parents 7109f31300fb
children 05e2bdc00c0c
comparison
equal deleted inserted replaced
72925:7109f31300fb 72926:db4aa878cea2
137 PyObject *outf; 137 PyObject *outf;
138 PyInterpreterState *interp = PyThreadState_GET()->interp; 138 PyInterpreterState *interp = PyThreadState_GET()->interp;
139 PyObject *modules = interp->modules; 139 PyObject *modules = interp->modules;
140 PyObject *builtins = PyDict_GetItemString(modules, "builtins"); 140 PyObject *builtins = PyDict_GetItemString(modules, "builtins");
141 int err; 141 int err;
142 _Py_IDENTIFIER(_);
142 143
143 if (builtins == NULL) { 144 if (builtins == NULL) {
144 PyErr_SetString(PyExc_RuntimeError, "lost builtins module"); 145 PyErr_SetString(PyExc_RuntimeError, "lost builtins module");
145 return NULL; 146 return NULL;
146 } 147 }
150 /* Before, set '_' to None to avoid recursion */ 151 /* Before, set '_' to None to avoid recursion */
151 if (o == Py_None) { 152 if (o == Py_None) {
152 Py_INCREF(Py_None); 153 Py_INCREF(Py_None);
153 return Py_None; 154 return Py_None;
154 } 155 }
155 if (PyObject_SetAttrString(builtins, "_", Py_None) != 0) 156 if (_PyObject_SetAttrId(builtins, &PyId__, Py_None) != 0)
156 return NULL; 157 return NULL;
157 outf = PySys_GetObject("stdout"); 158 outf = PySys_GetObject("stdout");
158 if (outf == NULL || outf == Py_None) { 159 if (outf == NULL || outf == Py_None) {
159 PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); 160 PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
160 return NULL; 161 return NULL;
172 return NULL; 173 return NULL;
173 } 174 }
174 } 175 }
175 if (PyFile_WriteString("\n", outf) != 0) 176 if (PyFile_WriteString("\n", outf) != 0)
176 return NULL; 177 return NULL;
177 if (PyObject_SetAttrString(builtins, "_", o) != 0) 178 if (_PyObject_SetAttrId(builtins, &PyId__, o) != 0)
178 return NULL; 179 return NULL;
179 Py_INCREF(Py_None); 180 Py_INCREF(Py_None);
180 return Py_None; 181 return Py_None;
181 } 182 }
182 183