summaryrefslogtreecommitdiffstats
path: root/Lib/sched.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2012-12-29 19:15:24 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2012-12-29 19:15:24 (GMT)
commit3c80ce45e4c5e9e1b2c4e72b52f4942de3b0078d (patch)
tree7ffce70de0781db49b99102ece0d07df820301df /Lib/sched.py
parentd1ced9e86a4652366e574a880636c7bd804f5475 (diff)
parentc04957bff3a53ba3d051b7c4148a48ec5238f3cb (diff)
downloadcpython-3c80ce45e4c5e9e1b2c4e72b52f4942de3b0078d.zip
cpython-3c80ce45e4c5e9e1b2c4e72b52f4942de3b0078d.tar.gz
cpython-3c80ce45e4c5e9e1b2c4e72b52f4942de3b0078d.tar.bz2
Issue #16641: Fix default values of sched.scheduler.enter arguments were modifiable.
Diffstat (limited to 'Lib/sched.py')
-rw-r--r--Lib/sched.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/sched.py b/Lib/sched.py
index e523bc1..4b1f7ac 100644
--- a/Lib/sched.py
+++ b/Lib/sched.py
@@ -50,6 +50,8 @@ class Event(namedtuple('Event', 'time, priority, action, argument, kwargs')):
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
- def enterabs(self, time, priority, action, argument=[], kwargs={}):
+ def enterabs(self, time, priority, action, argument=(), kwargs=_sentinel):
"""Enter a new event in the queue at an absolute time.
Returns an ID for the event which can be used to remove it,
if necessary.
"""
+ if kwargs is _sentinel:
+ kwargs = {}
with self._lock:
event = Event(time, priority, action, argument, kwargs)
heapq.heappush(self._queue, event)
return event # The ID
- def enter(self, delay, priority, action, argument=[], kwargs={}):
+ def enter(self, delay, priority, action, argument=(), kwargs=_sentinel):
"""A variant that specifies the time as a relative time.
This is actually the more commonly used interface.