Issue1768969

classification
Title: filter doesn't return passed in subclass type
Type: Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: cgroves, rajesh_battala, zyasoft
Priority: normal Keywords: test failure causes

Created on 2007-08-07.05:06:14 by cgroves, last changed 2008-09-14.02:04:18 by zyasoft.

Messages
msg1811 (view) Author: Charlie Groves (cgroves) Date: 2007-08-07.05:06:14
When the builtin function filter is applied to a subclass of list, tuple or str the returned object should also be of that type.

The lack of this feature caused some failures in test_builtin, so those have been commented out as explained in http://wiki.python.org/jython/JythonDeveloperGuide/VersionTransitionTestExclusions
msg1812 (view) Author: rajesh battala (rajesh_battala) Date: 2007-08-30.07:35:29
def dis(x):
    return x

class badstr(str):
    pass

print "test subclass of str"
res = filter(dis, badstr("1234"))
print "res=", res
print "type=", type(res),"\n"


output:-

test subclass of str
res= 1234
type= <type 'str'>

when i run this above prog i got the same o/p both in Jython and Python 

it returns base class type only instead of the Specific sub class type

can you comment on this !
thanks
msg1813 (view) Author: Charlie Groves (cgroves) Date: 2007-08-30.07:46:48
Search for this bug id, 1768969, in Lib/test/test_builtin.py and uncomment the test it's above.  That'll let you see the failure this bug is referencing.
msg1814 (view) Author: rajesh battala (rajesh_battala) Date: 2007-08-31.10:25:37
hi Charlie.
i have used mehendren patch.
now the test case is not failing .

Actually previously the test case if failing because of value mismatch not because of TypeMismatch.

Python is also returning the Base Type only instead of Subclass type.!
i have checked it.
thanks.
msg3578 (view) Author: Jim Baker (zyasoft) Date: 2008-09-14.02:04:17
Fixed in 2.5 by r4983
Tested by test_builtin.BuiltinTest.test_filter_subclasses
History
Date User Action Args
2008-09-14 02:04:18zyasoftsetstatus: open -> closed
nosy: + zyasoft
resolution: fixed
messages: + msg3578
2007-08-07 05:06:14cgrovescreate