| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2454,6 +2454,8 @@ update_lines_cols(void) | |||
| 2454 | 2454 | { | |
| 2455 | 2455 | PyObject *o; | |
| 2456 | 2456 | PyObject *m = PyImport_ImportModuleNoBlock("curses"); | |
| 2457 | + _Py_IDENTIFIER(LINES); | ||
| 2458 | + _Py_IDENTIFIER(COLS); | ||
| 2457 | 2459 | ||
| 2458 | 2460 | if (!m) | |
| 2459 | 2461 | return 0; | |
@@ -2463,12 +2465,13 @@ update_lines_cols(void) | |||
| 2463 | 2465 | Py_DECREF(m); | |
| 2464 | 2466 | return 0; | |
| 2465 | 2467 | } | |
| 2466 | - if (PyObject_SetAttrString(m, "LINES", o)) { | ||
| 2468 | + if (_PyObject_SetAttrId(m, &PyId_LINES, o)) { | ||
| 2467 | 2469 | Py_DECREF(m); | |
| 2468 | 2470 | Py_DECREF(o); | |
| 2469 | 2471 | return 0; | |
| 2470 | 2472 | } | |
| 2471 | - if (PyDict_SetItemString(ModDict, "LINES", o)) { | ||
| 2473 | + /* PyId_LINES.object will be initialized here. */ | ||
| 2474 | + if (PyDict_SetItem(ModDict, PyId_LINES.object, o)) { | ||
| 2472 | 2475 | Py_DECREF(m); | |
| 2473 | 2476 | Py_DECREF(o); | |
| 2474 | 2477 | return 0; | |
@@ -2479,12 +2482,12 @@ update_lines_cols(void) | |||
| 2479 | 2482 | Py_DECREF(m); | |
| 2480 | 2483 | return 0; | |
| 2481 | 2484 | } | |
| 2482 | - if (PyObject_SetAttrString(m, "COLS", o)) { | ||
| 2485 | + if (_PyObject_SetAttrId(m, &PyId_COLS, o)) { | ||
| 2483 | 2486 | Py_DECREF(m); | |
| 2484 | 2487 | Py_DECREF(o); | |
| 2485 | 2488 | return 0; | |
| 2486 | 2489 | } | |
| 2487 | - if (PyDict_SetItemString(ModDict, "COLS", o)) { | ||
| 2490 | + if (PyDict_SetItem(ModDict, PyId_COLS.object, o)) { | ||
| 2488 | 2491 | Py_DECREF(m); | |
| 2489 | 2492 | Py_DECREF(o); | |
| 2490 | 2493 | return 0; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4388,12 +4388,13 @@ static PyObject * | |||
| 4388 | 4388 | instantiate(PyObject *cls, PyObject *args) | |
| 4389 | 4389 | { | |
| 4390 | 4390 | PyObject *result = NULL; | |
| 4391 | + _Py_IDENTIFIER(__getinitargs__); | ||
| 4391 | 4392 | /* Caller must assure args are a tuple. Normally, args come from | |
| 4392 | 4393 | Pdata_poptuple which packs objects from the top of the stack | |
| 4393 | 4394 | into a newly created tuple. */ | |
| 4394 | 4395 | assert(PyTuple_Check(args)); | |
| 4395 | 4396 | if (Py_SIZE(args) > 0 || !PyType_Check(cls) || | |
| 4396 | - PyObject_HasAttrString(cls, "__getinitargs__")) { | ||
| 4397 | + _PyObject_HasAttrId(cls, &PyId___getinitargs__)) { | ||
| 4397 | 4398 | result = PyObject_CallObject(cls, args); | |
| 4398 | 4399 | } | |
| 4399 | 4400 | else { | |
@@ -5557,6 +5558,7 @@ Unpickler_init(UnpicklerObject *self, PyObject *args, PyObject *kwds) | |||
| 5557 | 5558 | PyObject *fix_imports = Py_True; | |
| 5558 | 5559 | char *encoding = NULL; | |
| 5559 | 5560 | char *errors = NULL; | |
| 5561 | + _Py_IDENTIFIER(persistent_load); | ||
| 5560 | 5562 | ||
| 5561 | 5563 | /* XXX: That is an horrible error message. But, I don't know how to do | |
| 5562 | 5564 | better... */ | |
@@ -5591,8 +5593,7 @@ Unpickler_init(UnpicklerObject *self, PyObject *args, PyObject *kwds) | |||
| 5591 | 5593 | if (self->fix_imports == -1) | |
| 5592 | 5594 | return -1; | |
| 5593 | 5595 | ||
| 5594 | - if (PyObject_HasAttrString((PyObject *)self, "persistent_load")) { | ||
| 5595 | - _Py_IDENTIFIER(persistent_load); | ||
| 5596 | + if (_PyObject_HasAttrId((PyObject *)self, &PyId_persistent_load)) { | ||
| 5596 | 5597 | self->pers_func = _PyObject_GetAttrId((PyObject *)self, | |
| 5597 | 5598 | &PyId_persistent_load); | |
| 5598 | 5599 | if (self->pers_func == NULL) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -626,6 +626,7 @@ tee(PyObject *self, PyObject *args) | |||
| 626 | 626 | { | |
| 627 | 627 | Py_ssize_t i, n=2; | |
| 628 | 628 | PyObject *it, *iterable, *copyable, *result; | |
| 629 | + _Py_IDENTIFIER(__copy__); | ||
| 629 | 630 | ||
| 630 | 631 | if (!PyArg_ParseTuple(args, "O|n", &iterable, &n)) | |
| 631 | 632 | return NULL; | |
@@ -643,7 +644,7 @@ tee(PyObject *self, PyObject *args) | |||
| 643 | 644 | Py_DECREF(result); | |
| 644 | 645 | return NULL; | |
| 645 | 646 | } | |
| 646 | - if (!PyObject_HasAttrString(it, "__copy__")) { | ||
| 647 | + if (!_PyObject_HasAttrId(it, &PyId___copy__)) { | ||
| 647 | 648 | copyable = tee_fromiterable(it); | |
| 648 | 649 | Py_DECREF(it); | |
| 649 | 650 | if (copyable == NULL) { | |
@@ -654,7 +655,6 @@ tee(PyObject *self, PyObject *args) | |||
| 654 | 655 | copyable = it; | |
| 655 | 656 | PyTuple_SET_ITEM(result, 0, copyable); | |
| 656 | 657 | for (i=1 ; i<n ; i++) { | |
| 657 | - _Py_IDENTIFIER(__copy__); | ||
| 658 | 658 | ||
| 659 | 659 | copyable = _PyObject_CallMethodId(copyable, &PyId___copy__, NULL); | |
| 660 | 660 | if (copyable == NULL) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1311,7 +1311,7 @@ property_init(PyObject *self, PyObject *args, PyObject *kwds) | |||
| 1311 | 1311 | in dict of the subclass instance instead, | |
| 1312 | 1312 | otherwise it gets shadowed by __doc__ in the | |
| 1313 | 1313 | class's dict. */ | |
| 1314 | - int err = PyObject_SetAttrString(self, "__doc__", get_doc); | ||
| 1314 | + int err = _PyObject_SetAttrId(self, &PyId___doc__, get_doc); | ||
| 1315 | 1315 | Py_DECREF(get_doc); | |
| 1316 | 1316 | if (err < 0) | |
| 1317 | 1317 | return -1; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1387,7 +1387,8 @@ dict_update_common(PyObject *self, PyObject *args, PyObject *kwds, char *methnam | |||
| 1387 | 1387 | result = -1; | |
| 1388 | 1388 | ||
| 1389 | 1389 | else if (arg != NULL) { | |
| 1390 | - if (PyObject_HasAttrString(arg, "keys")) | ||
| 1390 | + _Py_IDENTIFIER(keys); | ||
| 1391 | + if (_PyObject_HasAttrId(arg, &PyId_keys)) | ||
| 1391 | 1392 | result = PyDict_Merge(self, arg, 1); | |
| 1392 | 1393 | else | |
| 1393 | 1394 | result = PyDict_MergeFromSeq2(self, arg, 1); | |
@@ -2747,7 +2748,7 @@ dictviews_or(PyObject* self, PyObject *other) | |||
| 2747 | 2748 | { | |
| 2748 | 2749 | PyObject *result = PySet_New(self); | |
| 2749 | 2750 | PyObject *tmp; | |
| 2750 | - _Py_identifier(update); | ||
| 2751 | + _Py_IDENTIFIER(update); | ||
| 2751 | 2752 | ||
| 2752 | 2753 | if (result == NULL) | |
| 2753 | 2754 | return NULL; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -747,6 +747,7 @@ def visitModule(self, mod): | |||
| 747 | 747 | static int add_attributes(PyTypeObject* type, char**attrs, int num_fields) | |
| 748 | 748 | { | |
| 749 | 749 | int i, result; | |
| 750 | + _Py_IDENTIFIER(_attributes); | ||
| 750 | 751 | PyObject *s, *l = PyTuple_New(num_fields); | |
| 751 | 752 | if (!l) | |
| 752 | 753 | return 0; | |
@@ -758,7 +759,7 @@ def visitModule(self, mod): | |||
| 758 | 759 | } | |
| 759 | 760 | PyTuple_SET_ITEM(l, i, s); | |
| 760 | 761 | } | |
| 761 | - result = PyObject_SetAttrString((PyObject*)type, "_attributes", l) >= 0; | ||
| 762 | + result = _PyObject_SetAttrId((PyObject*)type, &PyId__attributes, l) >= 0; | ||
| 762 | 763 | Py_DECREF(l); | |
| 763 | 764 | return result; | |
| 764 | 765 | } | |
@@ -1024,7 +1025,7 @@ def visitSum(self, sum, name): | |||
| 1024 | 1025 | for a in sum.attributes: | |
| 1025 | 1026 | self.emit("value = ast2obj_%s(o->%s);" % (a.type, a.name), 1) | |
| 1026 | 1027 | self.emit("if (!value) goto failed;", 1) | |
| 1027 | - self.emit('if (PyObject_SetAttrString(result, "%s", value) < 0)' % a.name, 1) | ||
| 1028 | + self.emit('if (_PyObject_SetAttrId(result, &PyId_%s, value) < 0)' % a.name, 1) | ||
| 1028 | 1029 | self.emit('goto failed;', 2) | |
| 1029 | 1030 | self.emit('Py_DECREF(value);', 1) | |
| 1030 | 1031 | self.func_end() | |
@@ -1070,7 +1071,7 @@ def emit(s, d): | |||
| 1070 | 1071 | value = "o->v.%s.%s" % (name, field.name) | |
| 1071 | 1072 | self.set(field, value, depth) | |
| 1072 | 1073 | emit("if (!value) goto failed;", 0) | |
| 1073 | - emit('if (PyObject_SetAttrString(result, "%s", value) == -1)' % field.name, 0) | ||
| 1074 | + emit('if (_PyObject_SetAttrId(result, &PyId_%s, value) == -1)' % field.name, 0) | ||
| 1074 | 1075 | emit("goto failed;", 1) | |
| 1075 | 1076 | emit("Py_DECREF(value);", 0) | |
| 1076 | 1077 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments