Skip to content

Over-zealous keyword-arguments check for built-in set class #43345

Closed

Description

@dibatwork
mannequin
BPO 1486663
Nosy @birkenfeld, @rhettinger
Files
  • BuiltinSetKeywordArgumentsCheckBroken.py: BuiltinSetKeywordArgumentsCheckBroken.py
  • nokeywordchecks.diff
  • 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 = <Date 2007-02-19.08:21:52.000>
    created_at = <Date 2006-05-11.16:17:04.000>
    labels = ['interpreter-core', 'release-blocker']
    title = 'Over-zealous keyword-arguments check for built-in set class'
    updated_at = <Date 2007-02-19.08:21:52.000>
    user = 'https://bugs.python.org/dibatwork'

    bugs.python.org fields:

    activity = <Date 2007-02-19.08:21:52.000>
    actor = 'rhettinger'
    assignee = 'georg.brandl'
    closed = True
    closed_date = None
    closer = None
    components = ['Interpreter Core']
    creation = <Date 2006-05-11.16:17:04.000>
    creator = 'dib_at_work'
    dependencies = []
    files = ['2000', '2001']
    hgrepos = []
    issue_num = 1486663
    keywords = []
    message_count = 16.0
    messages = ['28478', '28479', '28480', '28481', '28482', '28483', '28484', '28485', '28486', '28487', '28488', '28489', '28490', '28491', '28492', '28493']
    nosy_count = 5.0
    nosy_names = ['nnorwitz', 'georg.brandl', 'rhettinger', 'zseil', 'dib_at_work']
    pr_nums = []
    priority = 'release blocker'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue1486663'
    versions = ['Python 2.5']

    Activity

    1. dibatwork commented on May 11, 2006

      dibatworkmannequin
      MannequinAuthor

      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.)

    2. added
      interpreter-core
      on May 11, 2006
    3. added
      interpreter-core
      on May 11, 2006
    4. birkenfeld commented on May 11, 2006

      @birkenfeld
      Member

      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.

    5. zseil commented on May 19, 2006

      zseilmannequin
      Mannequin

      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.

    6. zseil commented on May 20, 2006

      zseilmannequin
      Mannequin

      Logged In: YES
      user_id=1326842

      See patch bpo-1491939

    7. rhettinger commented on Jan 6, 2007

      @rhettinger
      Contributor

      I prefer the approach used by list().

    8. birkenfeld commented on Jan 10, 2007

      @birkenfeld
      Member

      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?

    9. rhettinger commented on Jan 11, 2007

      @rhettinger
      Contributor

      My proposed solution:

      • if(!PyArg_NoKeywords("set()", kwds)
        + if(type == &PySet_Type && !PyArg_NoKeywords("set()", kwds)
    10. rhettinger commented on Jan 11, 2007

      @rhettinger
      Contributor

      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.

    11. birkenfeld commented on Jan 11, 2007

      @birkenfeld
      Member

      Attaching patch.
      File Added: nokeywordchecks.diff

    12. rhettinger commented on Jan 11, 2007

      @rhettinger
      Contributor

      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

    13. nnorwitz commented on Jan 17, 2007

      nnorwitzmannequin
      Mannequin

      Were these changes applied by Raymond? I don't think there were NEWS entries though.

    14. birkenfeld commented on Jan 17, 2007

      @birkenfeld
      Member

      I'll create the testcases and commit the patch (as well as NEWS entries :) when I find the time.

    15. birkenfeld commented on Jan 21, 2007

      @birkenfeld
      Member

      Committed as rev. 53509, 53510 (2.5).

    16. rhettinger commented on Feb 19, 2007

      @rhettinger
      Contributor

      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))

    17. birkenfeld commented on Feb 19, 2007

      @birkenfeld
      Member

      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.

    18. rhettinger commented on Feb 19, 2007

      @rhettinger
      Contributor

      Okay, it looks like this bug was already fixed.

    19. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    interpreter-corerelease-blocker

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions