[ python-Bugs-1486663 ] Over-zealous keyword-arguments check for built-in set class
SourceForge.net
noreply at sourceforge.net
Thu Jan 11 19:30:18 CET 2007
Bugs item #1486663, was opened at 2006-05-11 11:17
Message generated for change (Comment added) made by rhettinger
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1486663&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.4
Status: Open
Resolution: None
>Priority: 7
Private: No
Submitted By: dib (dib_at_work)
>Assigned to: Georg Brandl (gbrandl)
Summary: Over-zealous keyword-arguments check for built-in set class
Initial Comment:
The fix for bug #1119418 (xrange() builtin accepts
keyword arg silently) included in Python 2.4.2c1+
breaks code that passes keyword argument(s) into
classes derived from the built-in set class, even if
those derived classes explictly accept those keyword
arguments and avoid passing them down to the built-in
base class.
Simplified version of code in attached
BuiltinSetKeywordArgumentsCheckBroken.py fails at (G)
due to bug #1119418 if version < 2.4.2c1; if version >=
2.4.2c1 (G) passes thanks to that bug fix, but instead
(H) incorrectly-in-my-view fails.
[Presume similar cases would fail for xrange and the
other classes mentioned in #1119418.]
-- David Bruce
(Tested on 2.4, 2.4.2, 2.5a2 on linux2, win32.)
----------------------------------------------------------------------
>Comment By: Raymond Hettinger (rhettinger)
Date: 2007-01-11 13:30
Message:
Logged In: YES
user_id=80475
Originator: NO
I fixed setobject.c in revisions 53380 and 53381.
Please apply similar fixes to all the other places being bitten my the
pervasive NoKeywords tests.
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2007-01-10 19:49
Message:
Logged In: YES
user_id=80475
Originator: NO
My proposed solution:
- if(!PyArg_NoKeywords("set()", kwds)
+ if(type == &PySet_Type && !PyArg_NoKeywords("set()", kwds)
----------------------------------------------------------------------
Comment By: Georg Brandl (gbrandl)
Date: 2007-01-10 16:30
Message:
Logged In: YES
user_id=849994
Originator: NO
I'll do that, only in set_init, you have
if (!PyArg_UnpackTuple(args, self->ob_type->tp_name, 0, 1, &iterable))
Changing this to use PyArg_ParseTupleAndKeywords would require a format
string of
"|O:" + self->ob_type->tp_name
Is it worth constructing that string each time set_init() is called or
should it just be "|O:set" for
sets and frozensets?
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2007-01-05 21:26
Message:
Logged In: YES
user_id=80475
Originator: NO
I prefer the approach used by list().
----------------------------------------------------------------------
Comment By: Žiga Seilnacht (zseil)
Date: 2006-05-19 20:19
Message:
Logged In: YES
user_id=1326842
See patch #1491939
----------------------------------------------------------------------
Comment By: Žiga Seilnacht (zseil)
Date: 2006-05-19 15:02
Message:
Logged In: YES
user_id=1326842
This bug was introduced as part of the fix for bug #1119418.
It also affects collections.deque.
Can't the _PyArg_NoKeywords check simply be moved
to set_init and deque_init as it was done for
zipimport.zipimporter?
array.array doesn't need to be changed, since it
already does all of its initialization in its
__new__ method.
The rest of the types changed in that fix should not
be affected, since they are immutable.
----------------------------------------------------------------------
Comment By: Georg Brandl (gbrandl)
Date: 2006-05-11 12:23
Message:
Logged In: YES
user_id=849994
Raymond, what to do in this case?
Note that other built-in types, such as list(), do accept
keyword arguments.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1486663&group_id=5470
More information about the Python-bugs-list
mailing list