| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -734,8 +734,7 @@ PyCStructType_setattro(PyObject *self, PyObject *key, PyObject *value) | |||
| 734 | 734 | return -1; | |
| 735 | 735 | ||
| 736 | 736 | if (value && PyUnicode_Check(key) && | |
| 737 | - /* XXX struni _PyUnicode_AsString can fail (also in other places)! */ | ||
| 738 | - 0 == strcmp(_PyUnicode_AsString(key), "_fields_")) | ||
| 737 | + _PyUnicode_EqualToASCIIString(key, "_fields_")) | ||
| 739 | 738 | return PyCStructUnionType_update_stgdict(self, value, 1); | |
| 740 | 739 | return 0; | |
| 741 | 740 | } | |
@@ -749,7 +748,7 @@ UnionType_setattro(PyObject *self, PyObject *key, PyObject *value) | |||
| 749 | 748 | return -1; | |
| 750 | 749 | ||
| 751 | 750 | if (PyUnicode_Check(key) && | |
| 752 | - 0 == strcmp(_PyUnicode_AsString(key), "_fields_")) | ||
| 751 | + _PyUnicode_EqualToASCIIString(key, "_fields_")) | ||
| 753 | 752 | return PyCStructUnionType_update_stgdict(self, value, 0); | |
| 754 | 753 | return 0; | |
| 755 | 754 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1670,7 +1670,9 @@ POINTER(PyObject *self, PyObject *cls) | |||
| 1670 | 1670 | return result; | |
| 1671 | 1671 | } | |
| 1672 | 1672 | if (PyUnicode_CheckExact(cls)) { | |
| 1673 | - char *name = _PyUnicode_AsString(cls); | ||
| 1673 | + const char *name = PyUnicode_AsUTF8(cls); | ||
| 1674 | + if (name == NULL) | ||
| 1675 | + return NULL; | ||
| 1674 | 1676 | buf = PyMem_Malloc(strlen(name) + 3 + 1); | |
| 1675 | 1677 | if (buf == NULL) | |
| 1676 | 1678 | return PyErr_NoMemory(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -925,11 +925,14 @@ static PyMethodDef oss_mixer_methods[] = { | |||
| 925 | 925 | static PyObject * | |
| 926 | 926 | oss_getattro(oss_audio_t *self, PyObject *nameobj) | |
| 927 | 927 | { | |
| 928 | - char *name = ""; | ||
| 928 | + const char *name = ""; | ||
| 929 | 929 | PyObject * rval = NULL; | |
| 930 | 930 | ||
| 931 | - if (PyUnicode_Check(nameobj)) | ||
| 932 | - name = _PyUnicode_AsString(nameobj); | ||
| 931 | + if (PyUnicode_Check(nameobj)) { | ||
| 932 | + name = PyUnicode_AsUTF8(nameobj); | ||
| 933 | + if (name == NULL) | ||
| 934 | + return NULL; | ||
| 935 | + } | ||
| 933 | 936 | ||
| 934 | 937 | if (strcmp(name, "closed") == 0) { | |
| 935 | 938 | rval = (self->fd == -1) ? Py_True : Py_False; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2024,16 +2024,18 @@ ast_for_atom(struct compiling *c, const node *n) | |||
| 2024 | 2024 | errtype = "value error"; | |
| 2025 | 2025 | if (errtype) { | |
| 2026 | 2026 | char buf[128]; | |
| 2027 | + const char *s = NULL; | ||
| 2027 | 2028 | PyObject *type, *value, *tback, *errstr; | |
| 2028 | 2029 | PyErr_Fetch(&type, &value, &tback); | |
| 2029 | 2030 | errstr = PyObject_Str(value); | |
| 2030 | - if (errstr) { | ||
| 2031 | - char *s = _PyUnicode_AsString(errstr); | ||
| 2031 | + if (errstr) | ||
| 2032 | + s = PyUnicode_AsUTF8(errstr); | ||
| 2033 | + if (s) { | ||
| 2032 | 2034 | PyOS_snprintf(buf, sizeof(buf), "(%s) %s", errtype, s); | |
| 2033 | - Py_DECREF(errstr); | ||
| 2034 | 2035 | } else { | |
| 2035 | 2036 | PyOS_snprintf(buf, sizeof(buf), "(%s) unknown error", errtype); | |
| 2036 | 2037 | } | |
| 2038 | + Py_XDECREF(errstr); | ||
| 2037 | 2039 | ast_error(c, n, buf); | |
| 2038 | 2040 | Py_DECREF(type); | |
| 2039 | 2041 | Py_XDECREF(value); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -147,6 +147,10 @@ _PyImport_LoadDynamicModuleWithSpec(PyObject *spec, FILE *fp) | |||
| 147 | 147 | /* Package context is needed for single-phase init */ | |
| 148 | 148 | oldcontext = _Py_PackageContext; | |
| 149 | 149 | _Py_PackageContext = PyUnicode_AsUTF8(name_unicode); | |
| 150 | + if (_Py_PackageContext == NULL) { | ||
| 151 | + _Py_PackageContext = oldcontext; | ||
| 152 | + goto error; | ||
| 153 | + } | ||
| 150 | 154 | m = p0(); | |
| 151 | 155 | _Py_PackageContext = oldcontext; | |
| 152 | 156 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments