diff Objects/stringobject.c @ 27521:17bfd5dbc0f1 legacy-trunk

Implement appropriate __getnewargs__ for all immutable subclassable builtin types. The special handling for these can now be removed from save_newobj(). Add some testing for this. Also add support for setting the 'fast' flag on the Python Pickler class, which suppresses use of the memo.
author Guido van Rossum <guido@python.org>
date Wed, 29 Jan 2003 17:58:45 +0000
parents c4150f7f6a69
children 8802de0da533
line wrap: on
line diff
--- a/Objects/stringobject.c	Wed Jan 29 16:58:31 2003 +0000
+++ b/Objects/stringobject.c	Wed Jan 29 17:58:45 2003 +0000
@@ -3045,6 +3045,12 @@
 
 #undef SPLIT_APPEND
 
+static PyObject *
+string_getnewargs(PyStringObject *v)
+{
+	return Py_BuildValue("(s#)", v->ob_sval, v->ob_size);
+}
+
 
 static PyMethodDef
 string_methods[] = {
@@ -3091,6 +3097,7 @@
 	 expandtabs__doc__},
 	{"splitlines", (PyCFunction)string_splitlines, METH_VARARGS,
 	 splitlines__doc__},
+	{"__getnewargs__",	(PyCFunction)string_getnewargs,	METH_NOARGS},
 	{NULL,     NULL}		     /* sentinel */
 };