Make unicode subclassable.
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index c25c5ac..a9b4eb2 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -5298,6 +5298,9 @@
     (getcharbufferproc) unicode_buffer_getcharbuf,
 };
 
+staticforward PyObject *
+unicode_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
+
 static PyObject *
 unicode_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
@@ -5306,7 +5309,8 @@
 	char *encoding = NULL;
 	char *errors = NULL;
 
-	assert(type == &PyUnicode_Type);
+	if (type != &PyUnicode_Type)
+		return unicode_subtype_new(type, args, kwds);
 	if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oss:unicode",
 					  kwlist, &x, &encoding, &errors))
 	    return NULL;
@@ -5315,6 +5319,32 @@
 	return PyUnicode_FromEncodedObject(x, encoding, errors);
 }
 
+static PyObject *
+unicode_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+	PyUnicodeObject *tmp, *new;
+	int n;
+
+	assert(PyType_IsSubtype(type, &PyUnicode_Type));
+	tmp = (PyUnicodeObject *)unicode_new(&PyUnicode_Type, args, kwds);
+	if (tmp == NULL)
+		return NULL;
+	assert(PyUnicode_Check(tmp));
+	new = (PyUnicodeObject *) type->tp_alloc(type, n = tmp->length);
+	if (new == NULL)
+		return NULL;
+	new->str = PyMem_NEW(Py_UNICODE, n+1);
+	if (new->str == NULL) {
+		_Py_ForgetReference((PyObject *)new);
+		PyObject_DEL(new);
+		return NULL;
+	}
+	Py_UNICODE_COPY(new->str, tmp->str, n+1);
+	new->length = n;
+	Py_DECREF(tmp);
+	return (PyObject *)new;
+}
+
 static char unicode_doc[] =
 "unicode(string [, encoding[, errors]]) -> object\n\
 \n\
@@ -5344,7 +5374,7 @@
     PyObject_GenericGetAttr, 		/* tp_getattro */
     0,			 		/* tp_setattro */
     &unicode_as_buffer,			/* tp_as_buffer */
-    Py_TPFLAGS_DEFAULT,			/* tp_flags */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
     unicode_doc,			/* tp_doc */
     0,					/* tp_traverse */
     0,					/* tp_clear */