summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2007-07-11 20:01:43 (GMT)
committerThomas Heller <theller@ctypes.org>2007-07-11 20:01:43 (GMT)
commitace8ba8d4b2757d9b0e6e77be83c7100fe6b5823 (patch)
tree9f5c2b0a9c993aba14d121710f0a3dbe12b36192 /Objects
parentf630dac17804f2121cefa66a3ef4752f5af6ce7f (diff)
downloadcpython-ace8ba8d4b2757d9b0e6e77be83c7100fe6b5823.zip
cpython-ace8ba8d4b2757d9b0e6e77be83c7100fe6b5823.tar.gz
cpython-ace8ba8d4b2757d9b0e6e77be83c7100fe6b5823.tar.bz2
Revert a wrong commit.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 974275e..891be61 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -44,7 +44,6 @@ static int
type_set_name(PyTypeObject *type, PyObject *value, void *context)
{
PyHeapTypeObject* et;
- char *name;
if (!(type->tp_flags & Py_TPFLAGS_HEAPTYPE)) {
PyErr_Format(PyExc_TypeError,
@@ -56,25 +55,19 @@ type_set_name(PyTypeObject *type, PyObject *value, void *context)
"can't delete %s.__name__", type->tp_name);
return -1;
}
- if (PyString_Check(value)) {
- value = PyUnicode_FromStringAndSize(PyString_AS_STRING(value),
- PyString_GET_SIZE(value));
+ if (PyUnicode_Check(value)) {
+ value = _PyUnicode_AsDefaultEncodedString(value, NULL);
if (value == NULL)
return -1;
- /* XXX Isn't here a refcount leak? */
}
- if (!PyUnicode_Check(value)) {
+ if (!PyString_Check(value)) {
PyErr_Format(PyExc_TypeError,
"can only assign string to %s.__name__, not '%s'",
type->tp_name, value->ob_type->tp_name);
return -1;
}
-
- name = PyUnicode_AsString(value);
- if (name == NULL)
- return -1;
-
- if (strlen(name) != PyUnicode_GET_SIZE(value)) {
+ if (strlen(PyString_AS_STRING(value))
+ != (size_t)PyString_GET_SIZE(value)) {
PyErr_Format(PyExc_ValueError,
"__name__ must not contain null bytes");
return -1;
@@ -87,7 +80,7 @@ type_set_name(PyTypeObject *type, PyObject *value, void *context)
Py_DECREF(et->ht_name);
et->ht_name = value;
- type->tp_name = name;
+ type->tp_name = PyString_AS_STRING(value);
return 0;
}
@@ -1665,7 +1658,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
}
/* Check arguments: (name, bases, dict) */
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "UO!O!:type", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "SO!O!:type", kwlist,
&name,
&PyTuple_Type, &bases,
&PyDict_Type, &dict))