Commit 394996b5 authored by Alexandre Vassalotti's avatar Alexandre Vassalotti

Issue #5373: Remove restriction on null bytes in docstrings of classes.

parent d76b9f18
...@@ -2178,17 +2178,13 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds) ...@@ -2178,17 +2178,13 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
char *doc_str; char *doc_str;
char *tp_doc; char *tp_doc;
doc_str = _PyUnicode_AsStringAndSize(doc, &len); doc_str = _PyUnicode_AsString(doc);
if (doc_str == NULL) { if (doc_str == NULL) {
Py_DECREF(type); Py_DECREF(type);
return NULL; return NULL;
} }
if ((Py_ssize_t)strlen(doc_str) != len) { /* Silently truncate the docstring if it contains null bytes. */
PyErr_SetString(PyExc_TypeError, len = strlen(doc_str);
"__doc__ contains null-bytes");
Py_DECREF(type);
return NULL;
}
tp_doc = (char *)PyObject_MALLOC(len + 1); tp_doc = (char *)PyObject_MALLOC(len + 1);
if (tp_doc == NULL) { if (tp_doc == NULL) {
Py_DECREF(type); Py_DECREF(type);
......
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