| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2ff8fb7 commit b37672d
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2798,20 +2798,22 @@ date_new(PyTypeObject *type, PyObject *args, PyObject *kw) | |||
| 2798 | 2798 | int day; | |
| 2799 | 2799 | ||
| 2800 | 2800 | /* Check for invocation from pickle with __getstate__ state */ | |
| 2801 | - if (PyTuple_GET_SIZE(args) == 1 && | ||
| 2802 | - PyBytes_Check(state = PyTuple_GET_ITEM(args, 0)) && | ||
| 2803 | - PyBytes_GET_SIZE(state) == _PyDateTime_DATE_DATASIZE && | ||
| 2804 | - MONTH_IS_SANE(PyBytes_AS_STRING(state)[2])) | ||
| 2805 | - { | ||
| 2806 | - PyDateTime_Date *me; | ||
| 2807 | - | ||
| 2808 | - me = (PyDateTime_Date *) (type->tp_alloc(type, 0)); | ||
| 2809 | - if (me != NULL) { | ||
| 2810 | - char *pdata = PyBytes_AS_STRING(state); | ||
| 2811 | - memcpy(me->data, pdata, _PyDateTime_DATE_DATASIZE); | ||
| 2812 | - me->hashcode = -1; | ||
| 2801 | + if (PyTuple_GET_SIZE(args) == 1) { | ||
| 2802 | + state = PyTuple_GET_ITEM(args, 0); | ||
| 2803 | + if (PyBytes_Check(state) && | ||
| 2804 | + PyBytes_GET_SIZE(state) == _PyDateTime_DATE_DATASIZE && | ||
| 2805 | + MONTH_IS_SANE(PyBytes_AS_STRING(state)[2])) | ||
| 2806 | + { | ||
| 2807 | + PyDateTime_Date *me; | ||
| 2808 | + | ||
| 2809 | + me = (PyDateTime_Date *) (type->tp_alloc(type, 0)); | ||
| 2810 | + if (me != NULL) { | ||
| 2811 | + char *pdata = PyBytes_AS_STRING(state); | ||
| 2812 | + memcpy(me->data, pdata, _PyDateTime_DATE_DATASIZE); | ||
| 2813 | + me->hashcode = -1; | ||
| 2814 | + } | ||
| 2815 | + return (PyObject *)me; | ||
| 2813 | 2816 | } | |
| 2814 | - return (PyObject *)me; | ||
| 2815 | 2817 | } | |
| 2816 | 2818 | ||
| 2817 | 2819 | if (PyArg_ParseTupleAndKeywords(args, kw, "iii", date_kws, | |
@@ -3913,43 +3915,46 @@ time_new(PyTypeObject *type, PyObject *args, PyObject *kw) | |||
| 3913 | 3915 | ||
| 3914 | 3916 | /* Check for invocation from pickle with __getstate__ state */ | |
| 3915 | 3917 | if (PyTuple_GET_SIZE(args) >= 1 && | |
| 3916 | - PyTuple_GET_SIZE(args) <= 2 && | ||
| 3917 | - PyBytes_Check(state = PyTuple_GET_ITEM(args, 0)) && | ||
| 3918 | - PyBytes_GET_SIZE(state) == _PyDateTime_TIME_DATASIZE && | ||
| 3919 | - (0x7F & ((unsigned char) (PyBytes_AS_STRING(state)[0]))) < 24) | ||
| 3918 | + PyTuple_GET_SIZE(args) <= 2) | ||
| 3920 | 3919 | { | |
| 3921 | - PyDateTime_Time *me; | ||
| 3922 | - char aware; | ||
| 3923 | - | ||
| 3924 | - if (PyTuple_GET_SIZE(args) == 2) { | ||
| 3925 | - tzinfo = PyTuple_GET_ITEM(args, 1); | ||
| 3926 | - if (check_tzinfo_subclass(tzinfo) < 0) { | ||
| 3927 | - PyErr_SetString(PyExc_TypeError, "bad " | ||
| 3928 | - "tzinfo state arg"); | ||
| 3929 | - return NULL; | ||
| 3930 | - } | ||
| 3931 | - } | ||
| 3932 | - aware = (char)(tzinfo != Py_None); | ||
| 3933 | - me = (PyDateTime_Time *) (type->tp_alloc(type, aware)); | ||
| 3934 | - if (me != NULL) { | ||
| 3935 | - char *pdata = PyBytes_AS_STRING(state); | ||
| 3936 | - | ||
| 3937 | - memcpy(me->data, pdata, _PyDateTime_TIME_DATASIZE); | ||
| 3938 | - me->hashcode = -1; | ||
| 3939 | - me->hastzinfo = aware; | ||
| 3940 | - if (aware) { | ||
| 3941 | - Py_INCREF(tzinfo); | ||
| 3942 | - me->tzinfo = tzinfo; | ||
| 3943 | - } | ||
| 3944 | - if (pdata[0] & (1 << 7)) { | ||
| 3945 | - me->data[0] -= 128; | ||
| 3946 | - me->fold = 1; | ||
| 3920 | + state = PyTuple_GET_ITEM(args, 0); | ||
| 3921 | + if (PyBytes_Check(state) && | ||
| 3922 | + PyBytes_GET_SIZE(state) == _PyDateTime_TIME_DATASIZE && | ||
| 3923 | + (0x7F & ((unsigned char) (PyBytes_AS_STRING(state)[0]))) < 24) | ||
| 3924 | + { | ||
| 3925 | + PyDateTime_Time *me; | ||
| 3926 | + char aware; | ||
| 3927 | + | ||
| 3928 | + if (PyTuple_GET_SIZE(args) == 2) { | ||
| 3929 | + tzinfo = PyTuple_GET_ITEM(args, 1); | ||
| 3930 | + if (check_tzinfo_subclass(tzinfo) < 0) { | ||
| 3931 | + PyErr_SetString(PyExc_TypeError, "bad " | ||
| 3932 | + "tzinfo state arg"); | ||
| 3933 | + return NULL; | ||
| 3934 | + } | ||
| 3947 | 3935 | } | |
| 3948 | - else { | ||
| 3949 | - me->fold = 0; | ||
| 3936 | + aware = (char)(tzinfo != Py_None); | ||
| 3937 | + me = (PyDateTime_Time *) (type->tp_alloc(type, aware)); | ||
| 3938 | + if (me != NULL) { | ||
| 3939 | + char *pdata = PyBytes_AS_STRING(state); | ||
| 3940 | + | ||
| 3941 | + memcpy(me->data, pdata, _PyDateTime_TIME_DATASIZE); | ||
| 3942 | + me->hashcode = -1; | ||
| 3943 | + me->hastzinfo = aware; | ||
| 3944 | + if (aware) { | ||
| 3945 | + Py_INCREF(tzinfo); | ||
| 3946 | + me->tzinfo = tzinfo; | ||
| 3947 | + } | ||
| 3948 | + if (pdata[0] & (1 << 7)) { | ||
| 3949 | + me->data[0] -= 128; | ||
| 3950 | + me->fold = 1; | ||
| 3951 | + } | ||
| 3952 | + else { | ||
| 3953 | + me->fold = 0; | ||
| 3954 | + } | ||
| 3950 | 3955 | } | |
| 3956 | + return (PyObject *)me; | ||
| 3951 | 3957 | } | |
| 3952 | - return (PyObject *)me; | ||
| 3953 | 3958 | } | |
| 3954 | 3959 | ||
| 3955 | 3960 | if (PyArg_ParseTupleAndKeywords(args, kw, "|iiiiO$i", time_kws, | |
@@ -4552,43 +4557,46 @@ datetime_new(PyTypeObject *type, PyObject *args, PyObject *kw) | |||
| 4552 | 4557 | ||
| 4553 | 4558 | /* Check for invocation from pickle with __getstate__ state */ | |
| 4554 | 4559 | if (PyTuple_GET_SIZE(args) >= 1 && | |
| 4555 | - PyTuple_GET_SIZE(args) <= 2 && | ||
| 4556 | - PyBytes_Check(state = PyTuple_GET_ITEM(args, 0)) && | ||
| 4557 | - PyBytes_GET_SIZE(state) == _PyDateTime_DATETIME_DATASIZE && | ||
| 4558 | - MONTH_IS_SANE(PyBytes_AS_STRING(state)[2] & 0x7F)) | ||
| 4560 | + PyTuple_GET_SIZE(args) <= 2) | ||
| 4559 | 4561 | { | |
| 4560 | - PyDateTime_DateTime *me; | ||
| 4561 | - char aware; | ||
| 4562 | - | ||
| 4563 | - if (PyTuple_GET_SIZE(args) == 2) { | ||
| 4564 | - tzinfo = PyTuple_GET_ITEM(args, 1); | ||
| 4565 | - if (check_tzinfo_subclass(tzinfo) < 0) { | ||
| 4566 | - PyErr_SetString(PyExc_TypeError, "bad " | ||
| 4567 | - "tzinfo state arg"); | ||
| 4568 | - return NULL; | ||
| 4569 | - } | ||
| 4570 | - } | ||
| 4571 | - aware = (char)(tzinfo != Py_None); | ||
| 4572 | - me = (PyDateTime_DateTime *) (type->tp_alloc(type , aware)); | ||
| 4573 | - if (me != NULL) { | ||
| 4574 | - char *pdata = PyBytes_AS_STRING(state); | ||
| 4575 | - | ||
| 4576 | - memcpy(me->data, pdata, _PyDateTime_DATETIME_DATASIZE); | ||
| 4577 | - me->hashcode = -1; | ||
| 4578 | - me->hastzinfo = aware; | ||
| 4579 | - if (aware) { | ||
| 4580 | - Py_INCREF(tzinfo); | ||
| 4581 | - me->tzinfo = tzinfo; | ||
| 4582 | - } | ||
| 4583 | - if (pdata[2] & (1 << 7)) { | ||
| 4584 | - me->data[2] -= 128; | ||
| 4585 | - me->fold = 1; | ||
| 4562 | + state = PyTuple_GET_ITEM(args, 0); | ||
| 4563 | + if (PyBytes_Check(state) && | ||
| 4564 | + PyBytes_GET_SIZE(state) == _PyDateTime_DATETIME_DATASIZE && | ||
| 4565 | + MONTH_IS_SANE(PyBytes_AS_STRING(state)[2] & 0x7F)) | ||
| 4566 | + { | ||
| 4567 | + PyDateTime_DateTime *me; | ||
| 4568 | + char aware; | ||
| 4569 | + | ||
| 4570 | + if (PyTuple_GET_SIZE(args) == 2) { | ||
| 4571 | + tzinfo = PyTuple_GET_ITEM(args, 1); | ||
| 4572 | + if (check_tzinfo_subclass(tzinfo) < 0) { | ||
| 4573 | + PyErr_SetString(PyExc_TypeError, "bad " | ||
| 4574 | + "tzinfo state arg"); | ||
| 4575 | + return NULL; | ||
| 4576 | + } | ||
| 4586 | 4577 | } | |
| 4587 | - else { | ||
| 4588 | - me->fold = 0; | ||
| 4578 | + aware = (char)(tzinfo != Py_None); | ||
| 4579 | + me = (PyDateTime_DateTime *) (type->tp_alloc(type , aware)); | ||
| 4580 | + if (me != NULL) { | ||
| 4581 | + char *pdata = PyBytes_AS_STRING(state); | ||
| 4582 | + | ||
| 4583 | + memcpy(me->data, pdata, _PyDateTime_DATETIME_DATASIZE); | ||
| 4584 | + me->hashcode = -1; | ||
| 4585 | + me->hastzinfo = aware; | ||
| 4586 | + if (aware) { | ||
| 4587 | + Py_INCREF(tzinfo); | ||
| 4588 | + me->tzinfo = tzinfo; | ||
| 4589 | + } | ||
| 4590 | + if (pdata[2] & (1 << 7)) { | ||
| 4591 | + me->data[2] -= 128; | ||
| 4592 | + me->fold = 1; | ||
| 4593 | + } | ||
| 4594 | + else { | ||
| 4595 | + me->fold = 0; | ||
| 4596 | + } | ||
| 4589 | 4597 | } | |
| 4598 | + return (PyObject *)me; | ||
| 4590 | 4599 | } | |
| 4591 | - return (PyObject *)me; | ||
| 4592 | 4600 | } | |
| 4593 | 4601 | ||
| 4594 | 4602 | if (PyArg_ParseTupleAndKeywords(args, kw, "iii|iiiiO$i", datetime_kws, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5858,14 +5858,20 @@ load_extension(UnpicklerObject *self, int nbytes) | |||
| 5858 | 5858 | /* Since the extension registry is manipulable via Python code, | |
| 5859 | 5859 | * confirm that pair is really a 2-tuple of strings. | |
| 5860 | 5860 | */ | |
| 5861 | - if (!PyTuple_Check(pair) || PyTuple_Size(pair) != 2 || | ||
| 5862 | - !PyUnicode_Check(module_name = PyTuple_GET_ITEM(pair, 0)) || | ||
| 5863 | - !PyUnicode_Check(class_name = PyTuple_GET_ITEM(pair, 1))) { | ||
| 5864 | - Py_DECREF(py_code); | ||
| 5865 | - PyErr_Format(PyExc_ValueError, "_inverted_registry[%ld] " | ||
| 5866 | - "isn't a 2-tuple of strings", code); | ||
| 5867 | - return -1; | ||
| 5861 | + if (!PyTuple_Check(pair) || PyTuple_Size(pair) != 2) { | ||
| 5862 | + goto error; | ||
| 5863 | + } | ||
| 5864 | + | ||
| 5865 | + module_name = PyTuple_GET_ITEM(pair, 0); | ||
| 5866 | + if (!PyUnicode_Check(module_name)) { | ||
| 5867 | + goto error; | ||
| 5868 | + } | ||
| 5869 | + | ||
| 5870 | + class_name = PyTuple_GET_ITEM(pair, 1); | ||
| 5871 | + if (!PyUnicode_Check(class_name)) { | ||
| 5872 | + goto error; | ||
| 5868 | 5873 | } | |
| 5874 | + | ||
| 5869 | 5875 | /* Load the object. */ | |
| 5870 | 5876 | obj = find_class(self, module_name, class_name); | |
| 5871 | 5877 | if (obj == NULL) { | |
@@ -5881,6 +5887,12 @@ load_extension(UnpicklerObject *self, int nbytes) | |||
| 5881 | 5887 | } | |
| 5882 | 5888 | PDATA_PUSH(self->stack, obj, -1); | |
| 5883 | 5889 | return 0; | |
| 5890 | + | ||
| 5891 | + error: | ||
| 5892 | + Py_DECREF(py_code); | ||
| 5893 | + PyErr_Format(PyExc_ValueError, "_inverted_registry[%ld] " | ||
| 5894 | + "isn't a 2-tuple of strings", code); | ||
| 5895 | + return -1; | ||
| 5884 | 5896 | } | |
| 5885 | 5897 | ||
| 5886 | 5898 | static int | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5983,9 +5983,12 @@ PyInit__ssl(void) | |||
| 5983 | 5983 | PyModule_AddIntConstant(m, "PROTO_TLSv1_2", PY_PROTO_TLSv1_2); | |
| 5984 | 5984 | PyModule_AddIntConstant(m, "PROTO_TLSv1_3", PY_PROTO_TLSv1_3); | |
| 5985 | 5985 | ||
| 5986 | - #define addbool(m, v, b) \ | ||
| 5987 | - Py_INCREF((b) ? Py_True : Py_False); \ | ||
| 5988 | - PyModule_AddObject((m), (v), (b) ? Py_True : Py_False); | ||
| 5986 | + #define addbool(m, key, value) \ | ||
| 5987 | + do { \ | ||
| 5988 | + PyObject *bool_obj = (value) ? Py_True : Py_False; \ | ||
| 5989 | + Py_INCREF(bool_obj); \ | ||
| 5990 | + PyModule_AddObject((m), (key), bool_obj); \ | ||
| 5991 | + } while (0) | ||
| 5989 | 5992 | ||
| 5990 | 5993 | #if HAVE_SNI | |
| 5991 | 5994 | addbool(m, "HAS_SNI", 1); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -833,7 +833,8 @@ PyWeakref_NewProxy(PyObject *ob, PyObject *callback) | |||
| 833 | 833 | to avoid violating the invariants of the list | |
| 834 | 834 | of weakrefs for ob. */ | |
| 835 | 835 | Py_DECREF(result); | |
| 836 | - Py_INCREF(result = proxy); | ||
| 836 | + result = proxy; | ||
| 837 | + Py_INCREF(result); | ||
| 837 | 838 | goto skip_insert; | |
| 838 | 839 | } | |
| 839 | 840 | prev = ref; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments