return -1;
if (value && PyUnicode_Check(key) &&
- /* XXX struni _PyUnicode_AsString can fail (also in other places)! */
- 0 == strcmp(_PyUnicode_AsString(key), "_fields_"))
+ _PyUnicode_EqualToASCIIString(key, "_fields_"))
return PyCStructUnionType_update_stgdict(self, value, 1);
return 0;
}
return -1;
if (PyUnicode_Check(key) &&
- 0 == strcmp(_PyUnicode_AsString(key), "_fields_"))
+ _PyUnicode_EqualToASCIIString(key, "_fields_"))
return PyCStructUnionType_update_stgdict(self, value, 0);
return 0;
}
return result;
}
if (PyUnicode_CheckExact(cls)) {
- char *name = _PyUnicode_AsString(cls);
+ const char *name = PyUnicode_AsUTF8(cls);
+ if (name == NULL)
+ return NULL;
buf = PyMem_Malloc(strlen(name) + 3 + 1);
if (buf == NULL)
return PyErr_NoMemory();
static PyObject *
oss_getattro(oss_audio_t *self, PyObject *nameobj)
{
- char *name = "";
+ const char *name = "";
PyObject * rval = NULL;
- if (PyUnicode_Check(nameobj))
- name = _PyUnicode_AsString(nameobj);
+ if (PyUnicode_Check(nameobj)) {
+ name = PyUnicode_AsUTF8(nameobj);
+ if (name == NULL)
+ return NULL;
+ }
if (strcmp(name, "closed") == 0) {
rval = (self->fd == -1) ? Py_True : Py_False;
errtype = "value error";
if (errtype) {
char buf[128];
+ const char *s = NULL;
PyObject *type, *value, *tback, *errstr;
PyErr_Fetch(&type, &value, &tback);
errstr = PyObject_Str(value);
- if (errstr) {
- char *s = _PyUnicode_AsString(errstr);
+ if (errstr)
+ s = PyUnicode_AsUTF8(errstr);
+ if (s) {
PyOS_snprintf(buf, sizeof(buf), "(%s) %s", errtype, s);
- Py_DECREF(errstr);
} else {
PyOS_snprintf(buf, sizeof(buf), "(%s) unknown error", errtype);
}
+ Py_XDECREF(errstr);
ast_error(c, n, buf);
Py_DECREF(type);
Py_XDECREF(value);
/* Package context is needed for single-phase init */
oldcontext = _Py_PackageContext;
_Py_PackageContext = PyUnicode_AsUTF8(name_unicode);
+ if (_Py_PackageContext == NULL) {
+ _Py_PackageContext = oldcontext;
+ goto error;
+ }
m = p0();
_Py_PackageContext = oldcontext;