You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Over-zealous keyword-arguments check for built-in set class #43345
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/birkenfeld'closed_at=<Date2007-02-19.08:21:52.000>created_at=<Date2006-05-11.16:17:04.000>labels= ['interpreter-core', 'release-blocker']
title='Over-zealous keyword-arguments check for built-in set class'updated_at=<Date2007-02-19.08:21:52.000>user='https://bugs.python.org/dibatwork'
The fix for bug bpo-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 bpo-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 bpo-1119418.]
That looks about right. Please add test cases that fail without the patch and succeed with the patch. Also, put a comment in Misc/NEWS. If the whole test suite passes, go ahead and check-in to Py2.5.1 and the head.
Thanks,
Raymond
nnorwitz commented on Jan 17, 2007
nnorwitzmannequin
Mannequin
More actions
Were these changes applied by Raymond? I don't think there were NEWS entries though.
bufferobject.c:236: if (!_PyArg_NoKeywords("buffer()", kw))
classobject.c:2261: if (!_PyArg_NoKeywords("instancemethod", kw))
exceptions.c:57: if (!_PyArg_NoKeywords(self->ob_type->tp_name, kwds))
funcobject.c:653: if (!_PyArg_NoKeywords("classmethod", kwds))
funcobject.c:810: if (!_PyArg_NoKeywords("staticmethod", kwds))
rangeobject.c:48: if (!_PyArg_NoKeywords("xrange()", kw))
sliceobject.c:197: if (!_PyArg_NoKeywords("slice()", kw))
typeobject.c:5773: if (!_PyArg_NoKeywords("super", kwds))
Activity
dibatwork commentedon May 11, 2006
The fix for bug bpo-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 bpo-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 bpo-1119418.]
-- David Bruce
(Tested on 2.4, 2.4.2, 2.5a2 on linux2, win32.)
birkenfeld commentedon May 11, 2006
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.
zseil commentedon May 19, 2006
Logged In: YES
user_id=1326842
This bug was introduced as part of the fix for bug bpo-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.
zseil commentedon May 20, 2006
Logged In: YES
user_id=1326842
See patch bpo-1491939
rhettinger commentedon Jan 6, 2007
I prefer the approach used by list().
birkenfeld commentedon Jan 10, 2007
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?
rhettinger commentedon Jan 11, 2007
My proposed solution:
+ if(type == &PySet_Type && !PyArg_NoKeywords("set()", kwds)
rhettinger commentedon Jan 11, 2007
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.
birkenfeld commentedon Jan 11, 2007
Attaching patch.
File Added: nokeywordchecks.diff
rhettinger commentedon Jan 11, 2007
That looks about right. Please add test cases that fail without the patch and succeed with the patch. Also, put a comment in Misc/NEWS. If the whole test suite passes, go ahead and check-in to Py2.5.1 and the head.
Thanks,
Raymond
nnorwitz commentedon Jan 17, 2007
Were these changes applied by Raymond? I don't think there were NEWS entries though.
birkenfeld commentedon Jan 17, 2007
I'll create the testcases and commit the patch (as well as NEWS entries :) when I find the time.
birkenfeld commentedon Jan 21, 2007
Committed as rev. 53509, 53510 (2.5).
rhettinger commentedon Feb 19, 2007
There are more of these that need to be fixed:
bufferobject.c:236: if (!_PyArg_NoKeywords("buffer()", kw))
classobject.c:2261: if (!_PyArg_NoKeywords("instancemethod", kw))
exceptions.c:57: if (!_PyArg_NoKeywords(self->ob_type->tp_name, kwds))
funcobject.c:653: if (!_PyArg_NoKeywords("classmethod", kwds))
funcobject.c:810: if (!_PyArg_NoKeywords("staticmethod", kwds))
rangeobject.c:48: if (!_PyArg_NoKeywords("xrange()", kw))
sliceobject.c:197: if (!_PyArg_NoKeywords("slice()", kw))
typeobject.c:5773: if (!_PyArg_NoKeywords("super", kwds))
birkenfeld commentedon Feb 19, 2007
The exceptions.c one is in __init__, so it is not a problem when the derived class doesn't pass along kwargs to super.__init__.
I deliberately left the others as they were since their type objects lack the Py_TPFLAGS_BASETYPE flag.
rhettinger commentedon Feb 19, 2007
Okay, it looks like this bug was already fixed.