Issue 16967: Keyword only argument default values are evaluated before other defaults (original) (raw)

Issue16967

Created on 2013-01-14 19:37 by Kay.Hayen, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (6)
msg179970 - (view) Author: Kay Hayen (Kay.Hayen) Date: 2013-01-14 19:37
Suprisingly, keyword only arguments become evaluated first: >>> def f(a=undefined1,*,b=undefined2):pass ... Traceback (most recent call last): File "", line 1, in NameError: name 'undefined2' is not defined It should be "undefined1". I am sure, this is going to surprise developers and breaks assumptions, people tend to make. So far (to my knowledge) nothing that was separated by a "," could be evaluated in a mixed order. Please consider to change this around.
msg179972 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2013-01-14 19:47
Looks like a bug to me, although it isn't likely to cause great harm.
msg181783 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2013-02-10 10:29
Agreed on it being a bug that we do it the wrong way around, but "Yikes!" at the idea of code where it makes a significant difference.
msg181808 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-02-10 14:32
New changeset d296cf1600a8 by Benjamin Peterson in branch 'default': evaluate positional defaults before keyword-only defaults (closes #16967) http://hg.python.org/cpython/rev/d296cf1600a8
msg181809 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-02-10 14:48
New changeset 6917402c6191 by Benjamin Peterson in branch 'default': evaluate lambda keyword-only defaults after positional defaults (#16967 again) http://hg.python.org/cpython/rev/6917402c6191
msg221151 - (view) Author: Kay Hayen (Kay.Hayen) Date: 2014-06-21 04:10
I can confirm that Python3.4 is not affected. Python 3.3 and 3.2 still are.
History
Date User Action Args
2022-04-11 14:57:40 admin set github: 61171
2014-06-21 04:10:09 Kay.Hayen set messages: +
2013-02-10 14:48:29 python-dev set messages: +
2013-02-10 14:32:36 python-dev set status: open -> closednosy: + python-devmessages: + resolution: fixedstage: resolved
2013-02-10 14:21:31 benjamin.peterson set assignee: benjamin.petersonnosy: + benjamin.peterson
2013-02-10 10:29:40 ncoghlan set nosy: + ncoghlanmessages: +
2013-01-14 22:42:43 Arfrever set nosy: + Arfrever
2013-01-14 19:47:51 georg.brandl set nosy: + georg.brandlmessages: + title: Keyword keyword only default parameters are evaluated before po -> Keyword only argument default values are evaluated before other defaults
2013-01-14 19:37:14 Kay.Hayen create