From: Raymond Hettinger Date: Fri, 24 Apr 2009 18:48:59 +0000 (+0000) Subject: Issue 5830: Events are now comparable when the time and type are the same. X-Git-Tag: 3.0~186 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a17fa01e64c7c495555ff29492569b45e525e1f;p=thirdparty%2FPython%2Fcpython.git Issue 5830: Events are now comparable when the time and type are the same. --- diff --git a/Lib/sched.py b/Lib/sched.py index aecdb2a47554..11bb0a3a1861 100644 --- a/Lib/sched.py +++ b/Lib/sched.py @@ -33,7 +33,13 @@ from collections import namedtuple __all__ = ["scheduler"] -Event = namedtuple('Event', 'time, priority, action, argument') +class Event(namedtuple('Event', 'time, priority, action, argument')): + def __eq__(s, o): return (s.time, s.priority) == (o.time, o.priority) + def __ne__(s, o): return (s.time, s.priority) != (o.time, o.priority) + def __lt__(s, o): return (s.time, s.priority) < (o.time, o.priority) + def __le__(s, o): return (s.time, s.priority) <= (o.time, o.priority) + def __gt__(s, o): return (s.time, s.priority) > (o.time, o.priority) + def __ge__(s, o): return (s.time, s.priority) >= (o.time, o.priority) class scheduler: def __init__(self, timefunc, delayfunc): diff --git a/Misc/NEWS b/Misc/NEWS index 99d44cd62bd4..34d41e6357dc 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -35,6 +35,9 @@ Core and Builtins Library ------- +- Issue 5830: The sched module no longer raises a TypeError when + prioritizing Events with the same time and priority. + - Issue #1161031: fix readwrite select flag handling: POLLPRI now results in a handle_expt_event call, not handle_read_event, and POLLERR and POLLNVAL now call handle_close, not handle_expt_event. Also,