From: <pj...@us...> - 2009-04-05 23:22:05
|
Revision: 6170 http://jython.svn.sourceforge.net/jython/?rev=6170&view=rev Author: pjenvey Date: 2009-04-05 23:21:56 +0000 (Sun, 05 Apr 2009) Log Message: ----------- type shouldn't actually have a __str__ Modified Paths: -------------- trunk/jython/Lib/test/test_class_jy.py trunk/jython/src/org/python/core/PyType.java Modified: trunk/jython/Lib/test/test_class_jy.py =================================================================== --- trunk/jython/Lib/test/test_class_jy.py 2009-04-05 22:13:33 UTC (rev 6169) +++ trunk/jython/Lib/test/test_class_jy.py 2009-04-05 23:21:56 UTC (rev 6170) @@ -336,9 +336,11 @@ Foo.keys = class_dict.keys assert sorted(Foo().keys()) == sorted(['a', 'b']), sorted(Foo().keys()) + class ClassMetaclassRepr(unittest.TestCase): - """Verifies #1131 is fixed""" + def test_repr_with_metaclass(self): + # http://bugs.jython.org/issue1131 class FooMetaclass(type): def __new__(cls, name, bases, attrs): return super(FooMetaclass, cls).__new__(cls, name, bases, attrs) @@ -347,7 +349,17 @@ __metaclass__ = FooMetaclass self.assertEqual("<class '%s.Foo'>" % __name__, repr(Foo)) + def test_metaclass_str(self): + class Foo(type): + def __repr__(cls): + return 'foo' + class Bar(object): + __metaclass__ = Foo + self.assertEqual(repr(Bar), 'foo') + # type.__str__ previously broke this + self.assertEqual(str(Bar), 'foo') + def test_main(): test_support.run_unittest(ClassGeneralTestCase, ClassNamelessModuleTestCase, Modified: trunk/jython/src/org/python/core/PyType.java =================================================================== --- trunk/jython/src/org/python/core/PyType.java 2009-04-05 22:13:33 UTC (rev 6169) +++ trunk/jython/src/org/python/core/PyType.java 2009-04-05 23:21:56 UTC (rev 6170) @@ -1312,7 +1312,7 @@ return numSlots; } - @ExposedMethod(names = {"__repr__", "__str__"}, doc = BuiltinDocs.type___str___doc) + @ExposedMethod(names = "__repr__", doc = BuiltinDocs.type___repr___doc) public String type_toString() { String kind; if (!builtin) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |