diff Objects/typeobject.c @ 54555:f48a05214281

Issue #5373: Remove restriction on null bytes in docstrings of classes.
author Alexandre Vassalotti <alexandre@peadrop.com>
date Thu, 04 Jun 2009 00:43:04 +0000
parents f9f997c1fd81
children 59cf5f808c24
line wrap: on
line diff
--- a/Objects/typeobject.c	Thu Jun 04 00:35:30 2009 +0000
+++ b/Objects/typeobject.c	Thu Jun 04 00:43:04 2009 +0000
@@ -2178,17 +2178,13 @@
 			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);