[issue17435] threading.Timer.__init__() should use immutable argument defaults for args and kwargs

Terry J. Reedy report at bugs.python.org
Thu Mar 28 03:14:22 CET 2013


Terry J. Reedy added the comment:

The reported behavior is not a bug by our usual standards. The code is exactly as documented.
manual: class threading.Timer(interval, function, args=[], kwargs={})
docstring: t = Timer(30.0, f, args=[], kwargs={})

Threading is not a beginner module. Any competent Python programmer who reads either of the above, or the code line you quoted, would expect exactly the behavior you report. I think we should presume that people who monkey-patch the class, which is an unusual thing to do, know what they are doing. The patch would break any such intentional usage. If the signature were to be changed, there should be a deprecation period first, preferably with a DeprecationWarning for mutation either through an instance or through .__init__.

I do not see anything special about this particular function. If we change this use of [] and {} as defaults, then we should look at all such uses in the stdlib -- after pydev discussion. But I currently think we should leave well enough alone.

The Timer class was added in Sept. 2001, rev 19727, issue #428326. The patch was written by Itamar Shtull-Trauring, approved by Guido, and reviewed and committed by Martin.

----------
nosy: +gvanrossum, loewis, terry.reedy

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


More information about the Python-bugs-list mailing list