Skip to content

The AC doesn't support properly positional-or-keyword arguments per default #125954

@skirpichev

Description

@skirpichev

Feature or enhancement

Proposal:

Currently, #125917 makes only last argument of the reduce to be positional-or-keyword. But with:

_functools.reduce

    function as func: object
    iterable as seq: object
    initial as result: object(c_default="NULL") = _functools._initial_missing

Apply a function of two arguments cumulatively to an iterable, from left to right.
[...]

it can't built the interpreter:

$ make -s
In file included from ./Include/internal/pycore_unicodeobject.h:14,
                 from ./Include/internal/pycore_floatobject.h:11,
                 from ./Include/internal/pycore_runtime.h:17,
                 from ./Include/internal/pycore_pystate.h:11,
                 from ./Include/internal/pycore_call.h:11,
                 from ./Modules/_functoolsmodule.c:2:
./Modules/clinic/_functoolsmodule.c.h: In function ‘_functools_reduce’:
./Include/internal/pycore_global_strings.h:797:41: error: ‘struct <anonymous>’ has no member named ‘_py_function’; did you mean ‘_py_func’?
  797 |      (_Py_SINGLETON(strings.identifiers._py_ ## NAME._ascii.ob_base))
      |                                         ^~~~
./Include/internal/pycore_global_objects.h:28:31: note: in definition of macro ‘_Py_GLOBAL_OBJECT’
   28 |     _PyRuntime.static_objects.NAME
      |                               ^~~~
./Include/internal/pycore_global_strings.h:797:7: note: in expansion of macro ‘_Py_SINGLETON’
  797 |      (_Py_SINGLETON(strings.identifiers._py_ ## NAME._ascii.ob_base))
      |       ^~~~~~~~~~~~~
./Modules/clinic/_functoolsmodule.c.h:104:23: note: in expansion of macro ‘_Py_ID’
  104 |         .ob_item = { &_Py_ID(function), &_Py_ID(iterable), &_Py_ID(initial), },
      |                       ^~~~~~
make: *** [Makefile:3630: Modules/_functoolsmodule.o] Error 1

With leading / (before function argument) I got:

$ ./python Tools/clinic/clinic.py Modules/_functoolsmodule.c
Error in file 'Modules/_functoolsmodule.c' on line 938:
Function 'reduce' has an unsupported group configuration. (Unexpected state 0.d)

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions