cpython: 1c9c0f92df65 (original) (raw)

Mercurial > cpython

changeset 81134:1c9c0f92df65 3.3

Issue #16641: Fix default values of sched.scheduler.enter arguments were modifiable. [#16641]

Serhiy Storchaka storchaka@gmail.com
date Sat, 29 Dec 2012 21:13:45 +0200
parents 5db0833f135b
children e22ebc34a8eb 467c46e312eb
files Doc/library/sched.rst Lib/sched.py Misc/NEWS
diffstat 3 files changed, 23 insertions(+), 11 deletions(-)[+] [-] Doc/library/sched.rst 23 Lib/sched.py 8 Misc/NEWS 3

line wrap: on

line diff

--- a/Doc/library/sched.rst +++ b/Doc/library/sched.rst @@ -36,19 +36,22 @@ Example:: >>> import sched, time >>> s = sched.scheduler(time.time, time.sleep)

.. _scheduler-objects: @@ -59,7 +62,7 @@ Scheduler Objects :class:scheduler instances have the following methods and attributes: -.. method:: scheduler.enterabs(time, priority, action, argument=[], kwargs={}) +.. method:: scheduler.enterabs(time, priority, action, argument=(), kwargs={}) Schedule a new event. The time argument should be a numeric type compatible with the return value of the timefunc function passed to the constructor. @@ -67,8 +70,10 @@ Scheduler Objects priority. Executing the event means executing action(*argument, **kwargs).

-.. method:: scheduler.enter(delay, priority, action, argument=[], kwargs={}) +.. method:: scheduler.enter(delay, priority, action, argument=(), kwargs={}) Schedule an event for delay more time units. Other than the relative time, the other arguments, the effect and the return value are the same as those for

--- a/Lib/sched.py +++ b/Lib/sched.py @@ -50,6 +50,8 @@ class Event(namedtuple('Event', 'time, p 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) +_sentinel = object() + class scheduler: def init(self, timefunc=_time, delayfunc=time.sleep): @@ -60,19 +62,21 @@ class scheduler: self.timefunc = timefunc self.delayfunc = delayfunc

Returns an ID for the event which can be used to remove it, if necessary. """

This is actually the more commonly used interface.

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -124,6 +124,9 @@ Core and Builtins Library ------- +- Issue #16641: Fix default values of sched.scheduler.enter arguments were