Changed to use 'U' argument to PyArg_ParseTuple, instead of manually checking for unicode objects.
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index 1a9781b..d9633af 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -525,10 +525,15 @@
return str(self.x) + format_spec
# class that returns a bad type from __format__
- class H:
+ class B:
def __format__(self, format_spec):
return 1.0
+ # class that is derived from string, used
+ # as a format spec
+ class C(str):
+ pass
+
self.assertEqual(format(3, ''), '3')
self.assertEqual(format(A(3), 'spec'), '3spec')
@@ -550,7 +555,10 @@
empty_format_spec(None)
# TypeError because self.__format__ returns the wrong type
- self.assertRaises(TypeError, format, H(), "")
+ self.assertRaises(TypeError, format, B(), "")
+
+ # make sure we can take a subclass of str as a format spec
+ self.assertEqual(format(0, C('10')), ' 0')
def test_getattr(self):
import sys