Commit b7d0a555 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Add 's'/'z' case to do_mkvalue

parent bc7d9616
......@@ -125,6 +125,36 @@ static PyObject* do_mkvalue(const char** p_format, va_list* p_va, int flags) noe
return v;
}
case 's':
case 'z': {
PyObject* v;
char* str = va_arg(*p_va, char*);
Py_ssize_t n;
if (**p_format == '#') {
++*p_format;
if (flags & FLAG_SIZE_T)
n = va_arg(*p_va, Py_ssize_t);
else
n = va_arg(*p_va, int);
} else
n = -1;
if (str == NULL) {
v = Py_None;
Py_INCREF(v);
} else {
if (n < 0) {
size_t m = strlen(str);
if (m > PY_SSIZE_T_MAX) {
PyErr_SetString(PyExc_OverflowError, "string too long for Python string");
return NULL;
}
n = (Py_ssize_t)m;
}
v = PyString_FromStringAndSize(str, n);
}
return v;
}
default:
RELEASE_ASSERT(0, "%c", *((*p_format) - 1));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment