[New-bugs-announce] [issue22556] datetime comparison with 'None' returning a TypeError

Ankit Dhebar report at bugs.python.org
Sun Oct 5 10:38:46 CEST 2014


New submission from Ankit Dhebar:

code snippet
student_tuple = [ ('ykjsdf', 'A', 17, datetime.date(2014,10,15)), ('accjr', 'C', 11, datetime.date(2013,05,05)), ('dgekw', 'B', 5, datetime.date(1987,03,03)) ]

Output for the above code works as expected.
o/p : [('dgekw', 'B', 5, datetime.date(1987, 3, 3)), ('accjr', 'C', 11, datetime.date(2013, 5, 5)), ('ykjsdf', 'A', 17, datetime.date(2014, 10, 15))]

but when you make one of the above datetime.date as 'None' like below

student_tuple = [ ('ykjsdf', 'A', 17, datetime.date(2014,10,15)), ('accjr', 'C', 11, None), ('dgekw', 'B', 5, datetime.date(1987,03,03)) ]
 
o/p : TypeError: can't compare datetime.date to NoneType

In my opinion, the 'NoneType' should appear either in the beginning or towards the end after sorting is done.

----------
components: Tests
files: sorting_func.py
messages: 228543
nosy: pythoner
priority: normal
severity: normal
status: open
title: datetime comparison with 'None' returning a TypeError
type: compile error
versions: Python 2.7
Added file: http://bugs.python.org/file36809/sorting_func.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22556>
_______________________________________


More information about the New-bugs-announce mailing list