Skip to content

Add keyword-only parameter support to PyArg_ParseTupleAndKeywords #58536

Closed

Description

@larryhastings
BPO 14328
Nosy @gpshead, @pitrou, @larryhastings, @benjaminp, @ericsnowcurrently
Files
  • larry.parsekwonly.diff.2.txt
  • larry.parsekwonly.diff.3.txt
  • larry.parsekwonly.diff.4.txt
  • larry.parsekwonly.diff.5.txt
  • larry.parsekwonly.diff.7.txt
  • 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/larryhastings'
    closed_at = <Date 2012-03-20.20:08:02.518>
    created_at = <Date 2012-03-15.21:49:18.370>
    labels = ['interpreter-core', 'type-feature']
    title = 'Add keyword-only parameter support to PyArg_ParseTupleAndKeywords'
    updated_at = <Date 2012-03-20.20:08:02.517>
    user = 'https://github.com/larryhastings'

    bugs.python.org fields:

    activity = <Date 2012-03-20.20:08:02.517>
    actor = 'larry'
    assignee = 'larry'
    closed = True
    closed_date = <Date 2012-03-20.20:08:02.518>
    closer = 'larry'
    components = ['Interpreter Core']
    creation = <Date 2012-03-15.21:49:18.370>
    creator = 'larry'
    dependencies = []
    files = ['24878', '24883', '24901', '24912', '24955']
    hgrepos = []
    issue_num = 14328
    keywords = []
    message_count = 16.0
    messages = ['155961', '155964', '155965', '155966', '155968', '155979', '155987', '155998', '156060', '156145', '156186', '156361', '156362', '156376', '156377', '156454']
    nosy_count = 7.0
    nosy_names = ['gregory.p.smith', 'pitrou', 'larry', 'benjamin.peterson', 'Arfrever', 'python-dev', 'eric.snow']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue14328'
    versions = ['Python 3.3']

    Activity

    1. larryhastings commented on Mar 15, 2012

      @larryhastings
      ContributorAuthor

      This has been split off from bpo-14127 at Antoine's request.

      The attached patch adds support for keyword-only arguments to the PyArg_ParseTupleAndKeywords() family of functions. Includes doc and test.

      I used '$' to indicate "all parameters after this are keyword-only"; since they must also be optional it must follow a '|'. (I would have used '*' but we already use that for 'U*' 's* etc.)

      The patch already received one review from Greg P. Smith on the previous issue; the patch I'm attaching here is the second revision incorporating his suggestions.

    2. benjaminp commented on Mar 15, 2012

      @benjaminp
      Contributor

      Why do you force them to be optional?

    3. larryhastings commented on Mar 15, 2012

      @larryhastings
      ContributorAuthor

      It frankly never occurred to me that you'd want mandatory keyword-only arguments. Implementing them as optional-only was easy; I'm not sure but making them possibly mandatory (or both!) might complicate matters.

      Is there a use case for 'em?

    4. benjaminp commented on Mar 15, 2012

      @benjaminp
      Contributor

      2012/3/15 Larry Hastings <report@bugs.python.org>:

      Larry Hastings <larry@hastings.org> added the comment:

      It frankly never occurred to me that you'd want mandatory keyword-only arguments.  Implementing them as optional-only was easy; I'm not sure but making them possibly mandatory (or both!) might complicate matters.

      Is there a use case for 'em?

      No idea, but at some point we might want them and it parallels the
      Python interface.

    5. larryhastings commented on Mar 15, 2012

      @larryhastings
      ContributorAuthor

      How about we leave it for now, and if we need it later we can fix the implementation. Adding that feature won't break existing calls--we'll just permit $ to occur before/without | in the format string.

    6. larryhastings commented on Mar 16, 2012

      @larryhastings
      ContributorAuthor

      BTW, I have the os.utime patch nearly ready for review; it works, it just needs doc and test. But it's dependent on this patch--and it'd be smoother if bpo-14127 were finished too. So I'll hold off on posting the new patch until the fates of these two are decided.

    7. benjaminp commented on Mar 16, 2012

      @benjaminp
      Contributor

      I want bpo-14325 to go in first.

    8. larryhastings commented on Mar 16, 2012

      @larryhastings
      ContributorAuthor

      Attached is r3 of my patch incorporated Benjamin's suggestions.

      I want bpo-14325 to go in first.

      Why do you care? If I get signoff before 14325 does please explain to me why I should wait. They don't touch the same lines; should be a clean merge no matter who goes first.

    9. benjaminp commented on Mar 16, 2012

      @benjaminp
      Contributor

      Shouldn't using vgetargs1 with '$' in the format string just be an error? vgetargs1 doesn't know anything about keyword arguments.

    10. larryhastings commented on Mar 17, 2012

      @larryhastings
      ContributorAuthor

      Shouldn't using vgetargs1 with '$' in the format string just be
      an error? vgetargs1 doesn't know anything about keyword arguments.

      Thank you for catching that! Serves me right for search-and-destroy style development--I'm not that familiar with getargs.c.

      Fixed, which is to say I removed that gunk, in attached patch #4 against current trunk.

    11. larryhastings commented on Mar 17, 2012

      @larryhastings
      ContributorAuthor

      Incorporated the latest round of suggestions from Benjamin's most recent--and very thorough!--review. Thanks, Benjamin!

    12. larryhastings commented on Mar 19, 2012

      @larryhastings
      ContributorAuthor

      Anyone else? Or can I get the go-ahead?

    13. benjaminp commented on Mar 19, 2012

      @benjaminp
      Contributor

      Did you not see Georg's comments?

    14. larryhastings commented on Mar 20, 2012

      @larryhastings
      ContributorAuthor

      Whoops! Actually, I did. But then I promptly forgot about them. They're now all incorporated; please see attached patch.

    15. benjaminp commented on Mar 20, 2012

      @benjaminp
      Contributor

      Fine with me now.

      2012/3/19 Larry Hastings <report@bugs.python.org>:

      Larry Hastings <larry@hastings.org> added the comment:

      Whoops!  Actually, I did.  But then I promptly forgot about them.  They're now all incorporated; please see attached patch.

      ----------
      Added file: http://bugs.python.org/file24955/larry.parsekwonly.diff.7.txt


      Python tracker <report@bugs.python.org>
      <http://bugs.python.org/issue14328\>


    16. python-dev commented on Mar 20, 2012

      python-devmannequin
      Mannequin

      New changeset 052779d34945 by Larry Hastings in branch 'default':
      Issue bpo-14328: Add keyword-only parameters to PyArg_ParseTupleAndKeywords.
      http://hg.python.org/cpython/rev/052779d34945

    17. 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-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions