[Python-3000-checkins] r59899 - in python/branches/py3k: Lib/test/test_builtin.py Objects/typeobject.c
eric.smith
python-3000-checkins at python.org
Fri Jan 11 01:17:22 CET 2008
Author: eric.smith
Date: Fri Jan 11 01:17:22 2008
New Revision: 59899
Modified:
python/branches/py3k/Lib/test/test_builtin.py
python/branches/py3k/Objects/typeobject.c
Log:
Simplifed argument parsing in object.__format__, added test case.
Modified: python/branches/py3k/Lib/test/test_builtin.py
==============================================================================
--- python/branches/py3k/Lib/test/test_builtin.py (original)
+++ python/branches/py3k/Lib/test/test_builtin.py Fri Jan 11 01:17:22 2008
@@ -558,6 +558,10 @@
# TypeError because self.__format__ returns the wrong type
self.assertRaises(TypeError, format, B(), "")
+ # TypeError because format_spec is not unicode
+ self.assertRaises(TypeError, format, object(), 4)
+ self.assertRaises(TypeError, format, object(), object())
+
# make sure we can take a subclass of str as a format spec
self.assertEqual(format(0, C('10')), ' 0')
Modified: python/branches/py3k/Objects/typeobject.c
==============================================================================
--- python/branches/py3k/Objects/typeobject.c (original)
+++ python/branches/py3k/Objects/typeobject.c Fri Jan 11 01:17:22 2008
@@ -2950,12 +2950,8 @@
PyObject *result = NULL;
PyObject *format_meth = NULL;
- if (!PyArg_ParseTuple(args, "O:__format__", &format_spec))
+ if (!PyArg_ParseTuple(args, "U:__format__", &format_spec))
return NULL;
- if (!PyUnicode_Check(format_spec)) {
- PyErr_SetString(PyExc_TypeError, "Unicode object required");
- return NULL;
- }
self_as_str = PyObject_Str(self);
if (self_as_str != NULL) {
More information about the Python-3000-checkins
mailing list