Commit 1c67dd9b authored by Martin v. Löwis's avatar Martin v. Löwis

Port SetAttrString/HasAttrString to SetAttrId/GetAttrId.

parent bd928fef
...@@ -2454,6 +2454,8 @@ update_lines_cols(void) ...@@ -2454,6 +2454,8 @@ update_lines_cols(void)
{ {
PyObject *o; PyObject *o;
PyObject *m = PyImport_ImportModuleNoBlock("curses"); PyObject *m = PyImport_ImportModuleNoBlock("curses");
_Py_IDENTIFIER(LINES);
_Py_IDENTIFIER(COLS);
if (!m) if (!m)
return 0; return 0;
...@@ -2463,12 +2465,13 @@ update_lines_cols(void) ...@@ -2463,12 +2465,13 @@ update_lines_cols(void)
Py_DECREF(m); Py_DECREF(m);
return 0; return 0;
} }
if (PyObject_SetAttrString(m, "LINES", o)) { if (_PyObject_SetAttrId(m, &PyId_LINES, o)) {
Py_DECREF(m); Py_DECREF(m);
Py_DECREF(o); Py_DECREF(o);
return 0; return 0;
} }
if (PyDict_SetItemString(ModDict, "LINES", o)) { /* PyId_LINES.object will be initialized here. */
if (PyDict_SetItem(ModDict, PyId_LINES.object, o)) {
Py_DECREF(m); Py_DECREF(m);
Py_DECREF(o); Py_DECREF(o);
return 0; return 0;
...@@ -2479,12 +2482,12 @@ update_lines_cols(void) ...@@ -2479,12 +2482,12 @@ update_lines_cols(void)
Py_DECREF(m); Py_DECREF(m);
return 0; return 0;
} }
if (PyObject_SetAttrString(m, "COLS", o)) { if (_PyObject_SetAttrId(m, &PyId_COLS, o)) {
Py_DECREF(m); Py_DECREF(m);
Py_DECREF(o); Py_DECREF(o);
return 0; return 0;
} }
if (PyDict_SetItemString(ModDict, "COLS", o)) { if (PyDict_SetItem(ModDict, PyId_COLS.object, o)) {
Py_DECREF(m); Py_DECREF(m);
Py_DECREF(o); Py_DECREF(o);
return 0; return 0;
......
...@@ -4388,12 +4388,13 @@ static PyObject * ...@@ -4388,12 +4388,13 @@ static PyObject *
instantiate(PyObject *cls, PyObject *args) instantiate(PyObject *cls, PyObject *args)
{ {
PyObject *result = NULL; PyObject *result = NULL;
_Py_IDENTIFIER(__getinitargs__);
/* Caller must assure args are a tuple. Normally, args come from /* Caller must assure args are a tuple. Normally, args come from
Pdata_poptuple which packs objects from the top of the stack Pdata_poptuple which packs objects from the top of the stack
into a newly created tuple. */ into a newly created tuple. */
assert(PyTuple_Check(args)); assert(PyTuple_Check(args));
if (Py_SIZE(args) > 0 || !PyType_Check(cls) || if (Py_SIZE(args) > 0 || !PyType_Check(cls) ||
PyObject_HasAttrString(cls, "__getinitargs__")) { _PyObject_HasAttrId(cls, &PyId___getinitargs__)) {
result = PyObject_CallObject(cls, args); result = PyObject_CallObject(cls, args);
} }
else { else {
...@@ -5557,6 +5558,7 @@ Unpickler_init(UnpicklerObject *self, PyObject *args, PyObject *kwds) ...@@ -5557,6 +5558,7 @@ Unpickler_init(UnpicklerObject *self, PyObject *args, PyObject *kwds)
PyObject *fix_imports = Py_True; PyObject *fix_imports = Py_True;
char *encoding = NULL; char *encoding = NULL;
char *errors = NULL; char *errors = NULL;
_Py_IDENTIFIER(persistent_load);
/* XXX: That is an horrible error message. But, I don't know how to do /* XXX: That is an horrible error message. But, I don't know how to do
better... */ better... */
...@@ -5591,8 +5593,7 @@ Unpickler_init(UnpicklerObject *self, PyObject *args, PyObject *kwds) ...@@ -5591,8 +5593,7 @@ Unpickler_init(UnpicklerObject *self, PyObject *args, PyObject *kwds)
if (self->fix_imports == -1) if (self->fix_imports == -1)
return -1; return -1;
if (PyObject_HasAttrString((PyObject *)self, "persistent_load")) { if (_PyObject_HasAttrId((PyObject *)self, &PyId_persistent_load)) {
_Py_IDENTIFIER(persistent_load);
self->pers_func = _PyObject_GetAttrId((PyObject *)self, self->pers_func = _PyObject_GetAttrId((PyObject *)self,
&PyId_persistent_load); &PyId_persistent_load);
if (self->pers_func == NULL) if (self->pers_func == NULL)
......
...@@ -626,6 +626,7 @@ tee(PyObject *self, PyObject *args) ...@@ -626,6 +626,7 @@ tee(PyObject *self, PyObject *args)
{ {
Py_ssize_t i, n=2; Py_ssize_t i, n=2;
PyObject *it, *iterable, *copyable, *result; PyObject *it, *iterable, *copyable, *result;
_Py_IDENTIFIER(__copy__);
if (!PyArg_ParseTuple(args, "O|n", &iterable, &n)) if (!PyArg_ParseTuple(args, "O|n", &iterable, &n))
return NULL; return NULL;
...@@ -643,7 +644,7 @@ tee(PyObject *self, PyObject *args) ...@@ -643,7 +644,7 @@ tee(PyObject *self, PyObject *args)
Py_DECREF(result); Py_DECREF(result);
return NULL; return NULL;
} }
if (!PyObject_HasAttrString(it, "__copy__")) { if (!_PyObject_HasAttrId(it, &PyId___copy__)) {
copyable = tee_fromiterable(it); copyable = tee_fromiterable(it);
Py_DECREF(it); Py_DECREF(it);
if (copyable == NULL) { if (copyable == NULL) {
...@@ -654,7 +655,6 @@ tee(PyObject *self, PyObject *args) ...@@ -654,7 +655,6 @@ tee(PyObject *self, PyObject *args)
copyable = it; copyable = it;
PyTuple_SET_ITEM(result, 0, copyable); PyTuple_SET_ITEM(result, 0, copyable);
for (i=1 ; i<n ; i++) { for (i=1 ; i<n ; i++) {
_Py_IDENTIFIER(__copy__);
copyable = _PyObject_CallMethodId(copyable, &PyId___copy__, NULL); copyable = _PyObject_CallMethodId(copyable, &PyId___copy__, NULL);
if (copyable == NULL) { if (copyable == NULL) {
......
...@@ -1311,7 +1311,7 @@ property_init(PyObject *self, PyObject *args, PyObject *kwds) ...@@ -1311,7 +1311,7 @@ property_init(PyObject *self, PyObject *args, PyObject *kwds)
in dict of the subclass instance instead, in dict of the subclass instance instead,
otherwise it gets shadowed by __doc__ in the otherwise it gets shadowed by __doc__ in the
class's dict. */ class's dict. */
int err = PyObject_SetAttrString(self, "__doc__", get_doc); int err = _PyObject_SetAttrId(self, &PyId___doc__, get_doc);
Py_DECREF(get_doc); Py_DECREF(get_doc);
if (err < 0) if (err < 0)
return -1; return -1;
......
...@@ -1387,7 +1387,8 @@ dict_update_common(PyObject *self, PyObject *args, PyObject *kwds, char *methnam ...@@ -1387,7 +1387,8 @@ dict_update_common(PyObject *self, PyObject *args, PyObject *kwds, char *methnam
result = -1; result = -1;
else if (arg != NULL) { else if (arg != NULL) {
if (PyObject_HasAttrString(arg, "keys")) _Py_IDENTIFIER(keys);
if (_PyObject_HasAttrId(arg, &PyId_keys))
result = PyDict_Merge(self, arg, 1); result = PyDict_Merge(self, arg, 1);
else else
result = PyDict_MergeFromSeq2(self, arg, 1); result = PyDict_MergeFromSeq2(self, arg, 1);
...@@ -2747,7 +2748,7 @@ dictviews_or(PyObject* self, PyObject *other) ...@@ -2747,7 +2748,7 @@ dictviews_or(PyObject* self, PyObject *other)
{ {
PyObject *result = PySet_New(self); PyObject *result = PySet_New(self);
PyObject *tmp; PyObject *tmp;
_Py_identifier(update); _Py_IDENTIFIER(update);
if (result == NULL) if (result == NULL)
return NULL; return NULL;
......
...@@ -747,6 +747,7 @@ static PyTypeObject* make_type(char *type, PyTypeObject* base, char**fields, int ...@@ -747,6 +747,7 @@ static PyTypeObject* make_type(char *type, PyTypeObject* base, char**fields, int
static int add_attributes(PyTypeObject* type, char**attrs, int num_fields) static int add_attributes(PyTypeObject* type, char**attrs, int num_fields)
{ {
int i, result; int i, result;
_Py_IDENTIFIER(_attributes);
PyObject *s, *l = PyTuple_New(num_fields); PyObject *s, *l = PyTuple_New(num_fields);
if (!l) if (!l)
return 0; return 0;
...@@ -758,7 +759,7 @@ static int add_attributes(PyTypeObject* type, char**attrs, int num_fields) ...@@ -758,7 +759,7 @@ static int add_attributes(PyTypeObject* type, char**attrs, int num_fields)
} }
PyTuple_SET_ITEM(l, i, s); PyTuple_SET_ITEM(l, i, s);
} }
result = PyObject_SetAttrString((PyObject*)type, "_attributes", l) >= 0; result = _PyObject_SetAttrId((PyObject*)type, &PyId__attributes, l) >= 0;
Py_DECREF(l); Py_DECREF(l);
return result; return result;
} }
...@@ -1024,7 +1025,7 @@ class ObjVisitor(PickleVisitor): ...@@ -1024,7 +1025,7 @@ class ObjVisitor(PickleVisitor):
for a in sum.attributes: for a in sum.attributes:
self.emit("value = ast2obj_%s(o->%s);" % (a.type, a.name), 1) self.emit("value = ast2obj_%s(o->%s);" % (a.type, a.name), 1)
self.emit("if (!value) goto failed;", 1) self.emit("if (!value) goto failed;", 1)
self.emit('if (PyObject_SetAttrString(result, "%s", value) < 0)' % a.name, 1) self.emit('if (_PyObject_SetAttrId(result, &PyId_%s, value) < 0)' % a.name, 1)
self.emit('goto failed;', 2) self.emit('goto failed;', 2)
self.emit('Py_DECREF(value);', 1) self.emit('Py_DECREF(value);', 1)
self.func_end() self.func_end()
...@@ -1070,7 +1071,7 @@ class ObjVisitor(PickleVisitor): ...@@ -1070,7 +1071,7 @@ class ObjVisitor(PickleVisitor):
value = "o->v.%s.%s" % (name, field.name) value = "o->v.%s.%s" % (name, field.name)
self.set(field, value, depth) self.set(field, value, depth)
emit("if (!value) goto failed;", 0) emit("if (!value) goto failed;", 0)
emit('if (PyObject_SetAttrString(result, "%s", value) == -1)' % field.name, 0) emit('if (_PyObject_SetAttrId(result, &PyId_%s, value) == -1)' % field.name, 0)
emit("goto failed;", 1) emit("goto failed;", 1)
emit("Py_DECREF(value);", 0) emit("Py_DECREF(value);", 0)
......
This diff is collapsed.
...@@ -654,8 +654,9 @@ warnings_warn_explicit(PyObject *self, PyObject *args, PyObject *kwds) ...@@ -654,8 +654,9 @@ warnings_warn_explicit(PyObject *self, PyObject *args, PyObject *kwds)
return NULL; return NULL;
if (module_globals) { if (module_globals) {
static PyObject *get_source_name = NULL; _Py_IDENTIFIER(get_source);
static PyObject *splitlines_name = NULL; _Py_IDENTIFIER(splitlines);
PyObject *tmp;
PyObject *loader; PyObject *loader;
PyObject *module_name; PyObject *module_name;
PyObject *source; PyObject *source;
...@@ -663,16 +664,12 @@ warnings_warn_explicit(PyObject *self, PyObject *args, PyObject *kwds) ...@@ -663,16 +664,12 @@ warnings_warn_explicit(PyObject *self, PyObject *args, PyObject *kwds)
PyObject *source_line; PyObject *source_line;
PyObject *returned; PyObject *returned;
if (get_source_name == NULL) { if ((tmp = _PyUnicode_FromId(&PyId_get_source)) == NULL)
get_source_name = PyUnicode_InternFromString("get_source"); return NULL;
if (!get_source_name) Py_DECREF(tmp);
return NULL; if ((tmp = _PyUnicode_FromId(&PyId_splitlines)) == NULL)
} return NULL;
if (splitlines_name == NULL) { Py_DECREF(tmp);
splitlines_name = PyUnicode_InternFromString("splitlines");
if (!splitlines_name)
return NULL;
}
/* Check/get the requisite pieces needed for the loader. */ /* Check/get the requisite pieces needed for the loader. */
loader = PyDict_GetItemString(module_globals, "__loader__"); loader = PyDict_GetItemString(module_globals, "__loader__");
...@@ -682,11 +679,11 @@ warnings_warn_explicit(PyObject *self, PyObject *args, PyObject *kwds) ...@@ -682,11 +679,11 @@ warnings_warn_explicit(PyObject *self, PyObject *args, PyObject *kwds)
goto standard_call; goto standard_call;
/* Make sure the loader implements the optional get_source() method. */ /* Make sure the loader implements the optional get_source() method. */
if (!PyObject_HasAttrString(loader, "get_source")) if (!_PyObject_HasAttrId(loader, &PyId_get_source))
goto standard_call; goto standard_call;
/* Call get_source() to get the source code. */ /* Call get_source() to get the source code. */
source = PyObject_CallMethodObjArgs(loader, get_source_name, source = PyObject_CallMethodObjArgs(loader, PyId_get_source.object,
module_name, NULL); module_name, NULL);
if (!source) if (!source)
return NULL; return NULL;
else if (source == Py_None) { else if (source == Py_None) {
...@@ -695,8 +692,9 @@ warnings_warn_explicit(PyObject *self, PyObject *args, PyObject *kwds) ...@@ -695,8 +692,9 @@ warnings_warn_explicit(PyObject *self, PyObject *args, PyObject *kwds)
} }
/* Split the source into lines. */ /* Split the source into lines. */
source_list = PyObject_CallMethodObjArgs(source, splitlines_name, source_list = PyObject_CallMethodObjArgs(source,
NULL); PyId_splitlines.object,
NULL);
Py_DECREF(source); Py_DECREF(source);
if (!source_list) if (!source_list)
return NULL; return NULL;
......
...@@ -4422,7 +4422,9 @@ import_from(PyObject *v, PyObject *name) ...@@ -4422,7 +4422,9 @@ import_from(PyObject *v, PyObject *name)
static int static int
import_all_from(PyObject *locals, PyObject *v) import_all_from(PyObject *locals, PyObject *v)
{ {
PyObject *all = PyObject_GetAttrString(v, "__all__"); _Py_IDENTIFIER(__all__);
_Py_IDENTIFIER(__dict__);
PyObject *all = _PyObject_GetAttrId(v, &PyId___all__);
PyObject *dict, *name, *value; PyObject *dict, *name, *value;
int skip_leading_underscores = 0; int skip_leading_underscores = 0;
int pos, err; int pos, err;
...@@ -4431,7 +4433,7 @@ import_all_from(PyObject *locals, PyObject *v) ...@@ -4431,7 +4433,7 @@ import_all_from(PyObject *locals, PyObject *v)
if (!PyErr_ExceptionMatches(PyExc_AttributeError)) if (!PyErr_ExceptionMatches(PyExc_AttributeError))
return -1; /* Unexpected error */ return -1; /* Unexpected error */
PyErr_Clear(); PyErr_Clear();
dict = PyObject_GetAttrString(v, "__dict__"); dict = _PyObject_GetAttrId(v, &PyId___dict__);
if (dict == NULL) { if (dict == NULL) {
if (!PyErr_ExceptionMatches(PyExc_AttributeError)) if (!PyErr_ExceptionMatches(PyExc_AttributeError))
return -1; return -1;
......
...@@ -780,6 +780,12 @@ void ...@@ -780,6 +780,12 @@ void
PyErr_SyntaxLocationEx(const char *filename, int lineno, int col_offset) PyErr_SyntaxLocationEx(const char *filename, int lineno, int col_offset)
{ {
PyObject *exc, *v, *tb, *tmp; PyObject *exc, *v, *tb, *tmp;
_Py_IDENTIFIER(filename);
_Py_IDENTIFIER(lineno);
_Py_IDENTIFIER(msg);
_Py_IDENTIFIER(offset);
_Py_IDENTIFIER(print_file_and_line);
_Py_IDENTIFIER(text);
/* add attributes for the line number and filename for the error */ /* add attributes for the line number and filename for the error */
PyErr_Fetch(&exc, &v, &tb); PyErr_Fetch(&exc, &v, &tb);
...@@ -790,7 +796,7 @@ PyErr_SyntaxLocationEx(const char *filename, int lineno, int col_offset) ...@@ -790,7 +796,7 @@ PyErr_SyntaxLocationEx(const char *filename, int lineno, int col_offset)
if (tmp == NULL) if (tmp == NULL)
PyErr_Clear(); PyErr_Clear();
else { else {
if (PyObject_SetAttrString(v, "lineno", tmp)) if (_PyObject_SetAttrId(v, &PyId_lineno, tmp))
PyErr_Clear(); PyErr_Clear();
Py_DECREF(tmp); Py_DECREF(tmp);
} }
...@@ -799,7 +805,7 @@ PyErr_SyntaxLocationEx(const char *filename, int lineno, int col_offset) ...@@ -799,7 +805,7 @@ PyErr_SyntaxLocationEx(const char *filename, int lineno, int col_offset)
if (tmp == NULL) if (tmp == NULL)
PyErr_Clear(); PyErr_Clear();
else { else {
if (PyObject_SetAttrString(v, "offset", tmp)) if (_PyObject_SetAttrId(v, &PyId_offset, tmp))
PyErr_Clear(); PyErr_Clear();
Py_DECREF(tmp); Py_DECREF(tmp);
} }
...@@ -809,35 +815,35 @@ PyErr_SyntaxLocationEx(const char *filename, int lineno, int col_offset) ...@@ -809,35 +815,35 @@ PyErr_SyntaxLocationEx(const char *filename, int lineno, int col_offset)
if (tmp == NULL) if (tmp == NULL)
PyErr_Clear(); PyErr_Clear();
else { else {
if (PyObject_SetAttrString(v, "filename", tmp)) if (_PyObject_SetAttrId(v, &PyId_filename, tmp))
PyErr_Clear(); PyErr_Clear();
Py_DECREF(tmp); Py_DECREF(tmp);
} }
tmp = PyErr_ProgramText(filename, lineno); tmp = PyErr_ProgramText(filename, lineno);
if (tmp) { if (tmp) {
if (PyObject_SetAttrString(v, "text", tmp)) if (_PyObject_SetAttrId(v, &PyId_text, tmp))
PyErr_Clear(); PyErr_Clear();
Py_DECREF(tmp); Py_DECREF(tmp);
} }
} }
if (PyObject_SetAttrString(v, "offset", Py_None)) { if (_PyObject_SetAttrId(v, &PyId_offset, Py_None)) {
PyErr_Clear(); PyErr_Clear();
} }
if (exc != PyExc_SyntaxError) { if (exc != PyExc_SyntaxError) {
if (!PyObject_HasAttrString(v, "msg")) { if (!_PyObject_HasAttrId(v, &PyId_msg)) {
tmp = PyObject_Str(v); tmp = PyObject_Str(v);
if (tmp) { if (tmp) {
if (PyObject_SetAttrString(v, "msg", tmp)) if (_PyObject_SetAttrId(v, &PyId_msg, tmp))
PyErr_Clear(); PyErr_Clear();
Py_DECREF(tmp); Py_DECREF(tmp);
} else { } else {
PyErr_Clear(); PyErr_Clear();
} }
} }
if (!PyObject_HasAttrString(v, "print_file_and_line")) { if (!_PyObject_HasAttrId(v, &PyId_print_file_and_line)) {
if (PyObject_SetAttrString(v, "print_file_and_line", if (_PyObject_SetAttrId(v, &PyId_print_file_and_line,
Py_None)) Py_None))
PyErr_Clear(); PyErr_Clear();
} }
} }
......
...@@ -810,6 +810,8 @@ create_stdio(PyObject* io, ...@@ -810,6 +810,8 @@ create_stdio(PyObject* io,
_Py_IDENTIFIER(open); _Py_IDENTIFIER(open);
_Py_IDENTIFIER(isatty); _Py_IDENTIFIER(isatty);
_Py_IDENTIFIER(TextIOWrapper); _Py_IDENTIFIER(TextIOWrapper);
_Py_IDENTIFIER(name);
_Py_IDENTIFIER(mode);
/* stdin is always opened in buffered mode, first because it shouldn't /* stdin is always opened in buffered mode, first because it shouldn't
make a difference in common use cases, second because TextIOWrapper make a difference in common use cases, second because TextIOWrapper
...@@ -842,7 +844,7 @@ create_stdio(PyObject* io, ...@@ -842,7 +844,7 @@ create_stdio(PyObject* io,
} }
text = PyUnicode_FromString(name); text = PyUnicode_FromString(name);
if (text == NULL || PyObject_SetAttrString(raw, "name", text) < 0) if (text == NULL || _PyObject_SetAttrId(raw, &PyId_name, text) < 0)
goto error; goto error;
res = _PyObject_CallMethodId(raw, &PyId_isatty, ""); res = _PyObject_CallMethodId(raw, &PyId_isatty, "");
if (res == NULL) if (res == NULL)
...@@ -879,7 +881,7 @@ create_stdio(PyObject* io, ...@@ -879,7 +881,7 @@ create_stdio(PyObject* io,
else else
mode = "r"; mode = "r";
text = PyUnicode_FromString(mode); text = PyUnicode_FromString(mode);
if (!text || PyObject_SetAttrString(stream, "mode", text) < 0) if (!text || _PyObject_SetAttrId(stream, &PyId_mode, text) < 0)
goto error; goto error;
Py_CLEAR(text); Py_CLEAR(text);
return stream; return stream;
...@@ -1547,6 +1549,7 @@ print_exception(PyObject *f, PyObject *value) ...@@ -1547,6 +1549,7 @@ print_exception(PyObject *f, PyObject *value)
{ {
int err = 0; int err = 0;
PyObject *type, *tb; PyObject *type, *tb;
_Py_IDENTIFIER(print_file_and_line);
if (!PyExceptionInstance_Check(value)) { if (!PyExceptionInstance_Check(value)) {
PyFile_WriteString("TypeError: print_exception(): Exception expected for value, ", f); PyFile_WriteString("TypeError: print_exception(): Exception expected for value, ", f);
...@@ -1562,7 +1565,7 @@ print_exception(PyObject *f, PyObject *value) ...@@ -1562,7 +1565,7 @@ print_exception(PyObject *f, PyObject *value)
if (tb && tb != Py_None) if (tb && tb != Py_None)
err = PyTraceBack_Print(tb, f); err = PyTraceBack_Print(tb, f);
if (err == 0 && if (err == 0 &&
PyObject_HasAttrString(value, "print_file_and_line")) _PyObject_HasAttrId(value, &PyId_print_file_and_line))
{ {
PyObject *message; PyObject *message;
const char *filename, *text; const char *filename, *text;
......
...@@ -139,6 +139,7 @@ sys_displayhook(PyObject *self, PyObject *o) ...@@ -139,6 +139,7 @@ sys_displayhook(PyObject *self, PyObject *o)
PyObject *modules = interp->modules; PyObject *modules = interp->modules;
PyObject *builtins = PyDict_GetItemString(modules, "builtins"); PyObject *builtins = PyDict_GetItemString(modules, "builtins");
int err; int err;
_Py_IDENTIFIER(_);
if (builtins == NULL) { if (builtins == NULL) {
PyErr_SetString(PyExc_RuntimeError, "lost builtins module"); PyErr_SetString(PyExc_RuntimeError, "lost builtins module");
...@@ -152,7 +153,7 @@ sys_displayhook(PyObject *self, PyObject *o) ...@@ -152,7 +153,7 @@ sys_displayhook(PyObject *self, PyObject *o)
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }
if (PyObject_SetAttrString(builtins, "_", Py_None) != 0) if (_PyObject_SetAttrId(builtins, &PyId__, Py_None) != 0)
return NULL; return NULL;
outf = PySys_GetObject("stdout"); outf = PySys_GetObject("stdout");
if (outf == NULL || outf == Py_None) { if (outf == NULL || outf == Py_None) {
...@@ -174,7 +175,7 @@ sys_displayhook(PyObject *self, PyObject *o) ...@@ -174,7 +175,7 @@ sys_displayhook(PyObject *self, PyObject *o)
} }
if (PyFile_WriteString("\n", outf) != 0) if (PyFile_WriteString("\n", outf) != 0)
return NULL; return NULL;
if (PyObject_SetAttrString(builtins, "_", o) != 0) if (_PyObject_SetAttrId(builtins, &PyId__, o) != 0)
return NULL; return NULL;
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
......
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