]> granicus.if.org Git - python/commitdiff
Issue #5373: Remove restriction on null bytes in docstrings of classes.
authorAlexandre Vassalotti <alexandre@peadrop.com>
Thu, 4 Jun 2009 00:43:04 +0000 (00:43 +0000)
committerAlexandre Vassalotti <alexandre@peadrop.com>
Thu, 4 Jun 2009 00:43:04 +0000 (00:43 +0000)
Objects/typeobject.c

index 0035f6d34c1216872ad35af7a683fe15ff519e7c..0e7954206bb1b7945ff2512cd20f30198cfa5deb 100644 (file)
@@ -2178,17 +2178,13 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
                        char *doc_str;
                        char *tp_doc;
 
-                       doc_str = _PyUnicode_AsStringAndSize(doc, &len);
+                       doc_str = _PyUnicode_AsString(doc);
                        if (doc_str == NULL) {
                                Py_DECREF(type);
                                return NULL;
                        }
-                       if ((Py_ssize_t)strlen(doc_str) != len) {
-                               PyErr_SetString(PyExc_TypeError,
-                                               "__doc__ contains null-bytes");
-                               Py_DECREF(type);
-                               return NULL;
-                       }
+                       /* Silently truncate the docstring if it contains null bytes. */
+                       len = strlen(doc_str);
                        tp_doc = (char *)PyObject_MALLOC(len + 1);
                        if (tp_doc == NULL) {
                                Py_DECREF(type);