| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7cf3d8e commit bb86bf4
21 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,10 +48,12 @@ PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void); | |||
| 48 | 48 | PyAPI_FUNC(PyObject *) PyEval_GetLocals(void); | |
| 49 | 49 | PyAPI_FUNC(struct _frame *) PyEval_GetFrame(void); | |
| 50 | 50 | ||
| 51 | + #ifndef Py_LIMITED_API | ||
| 52 | + /* Helper to look up a builtin object */ | ||
| 53 | + PyAPI_FUNC(PyObject *) _PyEval_GetBuiltinId(_Py_Identifier *); | ||
| 51 | 54 | /* Look at the current frame's (if any) code's co_flags, and turn on | |
| 52 | 55 | the corresponding compiler flags in cf->cf_flags. Return 1 if any | |
| 53 | 56 | flag was set, else return 0. */ | |
| 54 | - #ifndef Py_LIMITED_API | ||
| 55 | 57 | PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf); | |
| 56 | 58 | #endif | |
| 57 | 59 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -330,9 +330,6 @@ PyAPI_FUNC(int) | |||
| 330 | 330 | _PyObject_GenericSetAttrWithDict(PyObject *, PyObject *, | |
| 331 | 331 | PyObject *, PyObject *); | |
| 332 | 332 | ||
| 333 | - /* Helper to look up a builtin object */ | ||
| 334 | - PyAPI_FUNC(PyObject *) _PyObject_GetBuiltin(const char *name); | ||
| 335 | - | ||
| 336 | 333 | #define PyType_HasFeature(t,f) (((t)->tp_flags & (f)) != 0) | |
| 337 | 334 | ||
| 338 | 335 | static inline void _Py_Dealloc_inline(PyObject *op) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + Fixed error handling in pickling methods when fail to look up builtin | ||
| 2 | + "getattr". Sped up pickling iterators. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -209,19 +209,15 @@ _Pickle_ClearState(PickleState *st) | |||
| 209 | 209 | static int | |
| 210 | 210 | _Pickle_InitState(PickleState *st) | |
| 211 | 211 | { | |
| 212 | - PyObject *builtins; | ||
| 213 | 212 | PyObject *copyreg = NULL; | |
| 214 | 213 | PyObject *compat_pickle = NULL; | |
| 215 | 214 | PyObject *codecs = NULL; | |
| 216 | 215 | PyObject *functools = NULL; | |
| 216 | + _Py_IDENTIFIER(getattr); | ||
| 217 | 217 | ||
| 218 | - builtins = PyEval_GetBuiltins(); | ||
| 219 | - if (builtins == NULL) | ||
| 220 | - goto error; | ||
| 221 | - st->getattr = PyDict_GetItemString(builtins, "getattr"); | ||
| 218 | + st->getattr = _PyEval_GetBuiltinId(&PyId_getattr); | ||
| 222 | 219 | if (st->getattr == NULL) | |
| 223 | 220 | goto error; | |
| 224 | - Py_INCREF(st->getattr); | ||
| 225 | 221 | ||
| 226 | 222 | copyreg = PyImport_ImportModule("copyreg"); | |
| 227 | 223 | if (!copyreg) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2943,7 +2943,8 @@ static PyObject * | |||
| 2943 | 2943 | array_arrayiterator___reduce___impl(arrayiterobject *self) | |
| 2944 | 2944 | /*[clinic end generated code: output=7898a52e8e66e016 input=a062ea1e9951417a]*/ | |
| 2945 | 2945 | { | |
| 2946 | - PyObject *func = _PyObject_GetBuiltin("iter"); | ||
| 2946 | + _Py_IDENTIFIER(iter); | ||
| 2947 | + PyObject *func = _PyEval_GetBuiltinId(&PyId_iter); | ||
| 2947 | 2948 | if (self->ao == NULL) { | |
| 2948 | 2949 | return Py_BuildValue("N(())", func); | |
| 2949 | 2950 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -368,8 +368,9 @@ _grouper_next(_grouperobject *igo) | |||
| 368 | 368 | static PyObject * | |
| 369 | 369 | _grouper_reduce(_grouperobject *lz, PyObject *Py_UNUSED(ignored)) | |
| 370 | 370 | { | |
| 371 | + _Py_IDENTIFIER(iter); | ||
| 371 | 372 | if (((groupbyobject *)lz->parent)->currgrouper != lz) { | |
| 372 | - return Py_BuildValue("N(())", _PyObject_GetBuiltin("iter")); | ||
| 373 | + return Py_BuildValue("N(())", _PyEval_GetBuiltinId(&PyId_iter)); | ||
| 373 | 374 | } | |
| 374 | 375 | return Py_BuildValue("O(OO)", Py_TYPE(lz), lz->parent, lz->tgtkey); | |
| 375 | 376 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2358,11 +2358,12 @@ PyDoc_STRVAR(length_hint_doc, | |||
| 2358 | 2358 | static PyObject * | |
| 2359 | 2359 | bytearrayiter_reduce(bytesiterobject *it, PyObject *Py_UNUSED(ignored)) | |
| 2360 | 2360 | { | |
| 2361 | + _Py_IDENTIFIER(iter); | ||
| 2361 | 2362 | if (it->it_seq != NULL) { | |
| 2362 | - return Py_BuildValue("N(O)n", _PyObject_GetBuiltin("iter"), | ||
| 2363 | + return Py_BuildValue("N(O)n", _PyEval_GetBuiltinId(&PyId_iter), | ||
| 2363 | 2364 | it->it_seq, it->it_index); | |
| 2364 | 2365 | } else { | |
| 2365 | - return Py_BuildValue("N(())", _PyObject_GetBuiltin("iter")); | ||
| 2366 | + return Py_BuildValue("N(())", _PyEval_GetBuiltinId(&PyId_iter)); | ||
| 2366 | 2367 | } | |
| 2367 | 2368 | } | |
| 2368 | 2369 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3089,11 +3089,12 @@ PyDoc_STRVAR(length_hint_doc, | |||
| 3089 | 3089 | static PyObject * | |
| 3090 | 3090 | striter_reduce(striterobject *it, PyObject *Py_UNUSED(ignored)) | |
| 3091 | 3091 | { | |
| 3092 | + _Py_IDENTIFIER(iter); | ||
| 3092 | 3093 | if (it->it_seq != NULL) { | |
| 3093 | - return Py_BuildValue("N(O)n", _PyObject_GetBuiltin("iter"), | ||
| 3094 | + return Py_BuildValue("N(O)n", _PyEval_GetBuiltinId(&PyId_iter), | ||
| 3094 | 3095 | it->it_seq, it->it_index); | |
| 3095 | 3096 | } else { | |
| 3096 | - return Py_BuildValue("N(())", _PyObject_GetBuiltin("iter")); | ||
| 3097 | + return Py_BuildValue("N(())", _PyEval_GetBuiltinId(&PyId_iter)); | ||
| 3097 | 3098 | } | |
| 3098 | 3099 | } | |
| 3099 | 3100 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -78,18 +78,15 @@ method_reduce(PyMethodObject *im, PyObject *Py_UNUSED(ignored)) | |||
| 78 | 78 | { | |
| 79 | 79 | PyObject *self = PyMethod_GET_SELF(im); | |
| 80 | 80 | PyObject *func = PyMethod_GET_FUNCTION(im); | |
| 81 | - PyObject *builtins; | ||
| 82 | - PyObject *getattr; | ||
| 83 | 81 | PyObject *funcname; | |
| 84 | 82 | _Py_IDENTIFIER(getattr); | |
| 85 | 83 | ||
| 86 | 84 | funcname = _PyObject_GetAttrId(func, &PyId___name__); | |
| 87 | 85 | if (funcname == NULL) { | |
| 88 | 86 | return NULL; | |
| 89 | 87 | } | |
| 90 | - builtins = PyEval_GetBuiltins(); | ||
| 91 | - getattr = _PyDict_GetItemId(builtins, &PyId_getattr); | ||
| 92 | - return Py_BuildValue("O(ON)", getattr, self, funcname); | ||
| 88 | + return Py_BuildValue("N(ON)", _PyEval_GetBuiltinId(&PyId_getattr), | ||
| 89 | + self, funcname); | ||
| 93 | 90 | } | |
| 94 | 91 | ||
| 95 | 92 | static PyMethodDef method_methods[] = { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -452,14 +452,9 @@ descr_get_qualname(PyDescrObject *descr, void *Py_UNUSED(ignored)) | |||
| 452 | 452 | static PyObject * | |
| 453 | 453 | descr_reduce(PyDescrObject *descr, PyObject *Py_UNUSED(ignored)) | |
| 454 | 454 | { | |
| 455 | - PyObject *builtins; | ||
| 456 | - PyObject *getattr; | ||
| 457 | 455 | _Py_IDENTIFIER(getattr); | |
| 458 | - | ||
| 459 | - builtins = PyEval_GetBuiltins(); | ||
| 460 | - getattr = _PyDict_GetItemId(builtins, &PyId_getattr); | ||
| 461 | - return Py_BuildValue("O(OO)", getattr, PyDescr_TYPE(descr), | ||
| 462 | - PyDescr_NAME(descr)); | ||
| 456 | + return Py_BuildValue("N(OO)", _PyEval_GetBuiltinId(&PyId_getattr), | ||
| 457 | + PyDescr_TYPE(descr), PyDescr_NAME(descr)); | ||
| 463 | 458 | } | |
| 464 | 459 | ||
| 465 | 460 | static PyMethodDef descr_methods[] = { | |
@@ -1087,13 +1082,9 @@ wrapper_repr(wrapperobject *wp) | |||
| 1087 | 1082 | static PyObject * | |
| 1088 | 1083 | wrapper_reduce(wrapperobject *wp, PyObject *Py_UNUSED(ignored)) | |
| 1089 | 1084 | { | |
| 1090 | - PyObject *builtins; | ||
| 1091 | - PyObject *getattr; | ||
| 1092 | 1085 | _Py_IDENTIFIER(getattr); | |
| 1093 | - | ||
| 1094 | - builtins = PyEval_GetBuiltins(); | ||
| 1095 | - getattr = _PyDict_GetItemId(builtins, &PyId_getattr); | ||
| 1096 | - return Py_BuildValue("O(OO)", getattr, wp->self, PyDescr_NAME(wp->descr)); | ||
| 1086 | + return Py_BuildValue("N(OO)", _PyEval_GetBuiltinId(&PyId_getattr), | ||
| 1087 | + wp->self, PyDescr_NAME(wp->descr)); | ||
| 1097 | 1088 | } | |
| 1098 | 1089 | ||
| 1099 | 1090 | static PyMethodDef wrapper_methods[] = { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments