[Python-3000-checkins] r57493 - in python/branches/py3k: Lib/test/test_funcattrs.py Objects/funcobject.c

neal.norwitz python-3000-checkins at python.org
Sun Aug 26 05:56:04 CEST 2007


Author: neal.norwitz
Date: Sun Aug 26 05:56:04 2007
New Revision: 57493

Modified:
   python/branches/py3k/Lib/test/test_funcattrs.py
   python/branches/py3k/Objects/funcobject.c
Log:
Use unicode and stop supporting str8

Modified: python/branches/py3k/Lib/test/test_funcattrs.py
==============================================================================
--- python/branches/py3k/Lib/test/test_funcattrs.py	(original)
+++ python/branches/py3k/Lib/test/test_funcattrs.py	Sun Aug 26 05:56:04 2007
@@ -258,8 +258,8 @@
 def test_func_name():
     def f(): pass
     verify(f.__name__ == "f")
-    f.__name__ = str8("g")
-    verify(f.__name__ == str8("g"))
+    f.__name__ = "g"
+    verify(f.__name__ == "g")
     cantset(f, "__globals__", 1)
     cantset(f, "__name__", 1)
     # test that you can access func.__name__ in restricted mode

Modified: python/branches/py3k/Objects/funcobject.c
==============================================================================
--- python/branches/py3k/Objects/funcobject.c	(original)
+++ python/branches/py3k/Objects/funcobject.c	Sun Aug 26 05:56:04 2007
@@ -29,7 +29,7 @@
 		consts = ((PyCodeObject *)code)->co_consts;
 		if (PyTuple_Size(consts) >= 1) {
 			doc = PyTuple_GetItem(consts, 0);
-			if (!PyString_Check(doc) && !PyUnicode_Check(doc))
+			if (!PyUnicode_Check(doc))
 				doc = Py_None;
 		}
 		else
@@ -44,7 +44,7 @@
 		   Otherwise, use None.
 		*/
 		if (!__name__) {
-			__name__ = PyString_InternFromString("__name__");
+			__name__ = PyUnicode_InternFromString("__name__");
 			if (!__name__) {
 				Py_DECREF(op);
 				return NULL;
@@ -297,7 +297,7 @@
 		PyErr_Format(PyExc_ValueError,
 			     "%s() requires a code object with %zd free vars,"
 			     " not %zd",
-			     PyString_AsString(op->func_name),
+			     PyUnicode_AsString(op->func_name),
 			     nclosure, nfree);
 		return -1;
 	}
@@ -322,7 +322,7 @@
 
 	/* Not legal to del f.func_name or to set it to anything
 	 * other than a string object. */
-	if (value == NULL || (!PyString_Check(value) && !PyUnicode_Check(value))) {
+	if (value == NULL || !PyUnicode_Check(value)) {
 		PyErr_SetString(PyExc_TypeError,
 				"__name__ must be set to a string object");
 		return -1;
@@ -482,12 +482,7 @@
 			      &PyDict_Type, &globals,
 			      &name, &defaults, &closure))
 		return NULL;
-        if (PyUnicode_Check(name)) {
-		name = _PyUnicode_AsDefaultEncodedString(name, NULL);
-		if (name == NULL)
-			return NULL;
-	}
-	if (name != Py_None && !PyString_Check(name)) {
+	if (name != Py_None && !PyUnicode_Check(name)) {
 		PyErr_SetString(PyExc_TypeError,
 				"arg 3 (name) must be None or string");
 		return NULL;
@@ -573,9 +568,8 @@
 static PyObject*
 func_repr(PyFunctionObject *op)
 {
-	return PyUnicode_FromFormat("<function %s at %p>",
-				   PyString_AsString(op->func_name),
-				   op);
+	return PyUnicode_FromFormat("<function %U at %p>",
+				   op->func_name, op);
 }
 
 static int


More information about the Python-3000-checkins mailing list