]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Make test_new pass.
authorGuido van Rossum <guido@python.org>
Thu, 17 May 2007 21:15:39 +0000 (21:15 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 17 May 2007 21:15:39 +0000 (21:15 +0000)
Lib/test/test_new.py
Objects/funcobject.c

index 797a8c349f3181577913de04de0f11b27fe42851..c919621d7c3414141020f4f21d1c9c9226305f5a 100644 (file)
@@ -143,7 +143,7 @@ class NewTest(unittest.TestCase):
                 firstlineno, lnotab)
 
             # new.code used to be a way to mutate a tuple...
-            class S(str):
+            class S(str8):
                 pass
             t = (S("ab"),)
             d = new.code(argcount, kwonlyargcount, nlocals, stacksize,
index adbb6d51ab3eb73456ee81137fa658d274ec7a59..0069fc1bbc86e600f8651879fa4823b5866ebb52 100644 (file)
@@ -482,6 +482,11 @@ func_new(PyTypeObject* type, PyObject* args, PyObject* kw)
                              &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)) {
                PyErr_SetString(PyExc_TypeError,
                                "arg 3 (name) must be None or string");