New submission from Serhiy Storchaka:
Example:
>>> import sched
>>> s=sched.scheduler()
>>> s.enter(10, 1, print)
Event(time=7452.676787873, priority=1, action=<built-in function print>,
argument=[], kwargs={})
>>> next(s.queue).argument.append("spam")
>>> s.enter(5, 1, print)
Event(time=7473.326011725, priority=1, action=<built-in function print>,
argument=['spam'], kwargs={})
>>> s.run()
spam
spam
Now every s.enter() call (even for other schedulers) without explicit
"argument" use ['spam'] as "argument".
Usually functions should not have modifiable arguments (unless it is
intentional). We should use non-modifiable value or a sentinel for default. For
example an empty tuple as default for "argument" and None as default for
"kwargs".
----------
components: Library (Lib)
files: sched_nonmodifiable_args.patch
keywords: patch
messages: 177151
nosy: giampaolo.rodola, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: sched.scheduler.enter arguments should be modifiable
type: behavior
versions: Python 3.3, Python 3.4
Added file: http://bugs.python.org/file28256/sched_nonmodifiable_args.patch
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue16641>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com