GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Argument Clinic: move converters defined in several files to libclinic · Issue #156261 · python/cpython

Argument Clinic: move converters defined in several files to libclinic #156261

New issue
Copy link
New issue
Copy link
Open
Open
Argument Clinic: move converters defined in several files to libclinic#156261
Copy link
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtopic-argument-clinictype-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)

Description

@serhiy-storchaka
serhiy-storchaka
opened on Aug 23, 2026
Issue body actions

Several custom converters are defined in more than one C file:

  • pid_t — in posixmodule.c, _posixsubprocess.c and resource.c.
  • Py_off_t — in posixmodule.c and _ssl.c; the Py_off_t type and the converter function are duplicated as well, and _io has yet another copy of the type.
  • HANDLE — in _multiprocessing/multiprocessing.c, overlapped.c, msvcrtmodule.c, _testconsole.c and _winapi.c.
  • DWORD — in overlapped.c, winreg.c and _winapi.c.
  • BOOL — in overlapped.c and _winapi.c.

The copies are not always equivalent: two of the pid_t converters compare the result with -1 instead of (pid_t)-1, and DWORD in _winapi.c uses the format unit "k", which accepts negative values, while in other modules it rejects them.

The registry of converters is global, so the definition in the file which is processed first can be used in other files. The generated code therefore depends on the order of processing — removing the definition of HANDLE from one module silently changes the code generated for others.

Other converters are defined only in posixmodule.c, although the corresponding C functions are already shared, so other modules convert the argument in the "impl" function instead of declaring its type:

  • uid_t and gid_t — _Py_Uid_Converter() and _Py_Gid_Converter() are declared in posixmodule.h and are called by hand in pwd.getpwuid(), grp.getgrgid() and _posixsubprocess.fork_exec().

There is no converter for time_t at all: time.gmtime(), time.localtime() and time.ctime() parse their argument with a hand-written helper, and _datetime calls _PyTime_ObjectToTime_t() directly.

I am going to move these converters to Tools/clinic/libclinic/converters.py.

Linked PRs

  • gh-156261: Move converters used in several files to Argument Clinic #156262
  • gh-156261: Use the uid_t and gid_t converters in the pwd and grp modules #156294

Activity

  1. serhiy-storchaka
    added
    extension-modulesC modules in the Modules dirC modules in the Modules dir
    topic-argument-clinic
    type-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)
    on Aug 23, 2026
  2. serhiy-storchaka
    added a commit that references this issue on Aug 23, 2026

    gh-156261: Move converters used in several files to Argument Clinic (G…

    2c47c65
  3. clin1234
    added a commit that references this issue on Aug 27, 2026

    pythongh-156261: Move converters used in several files to Argument Cl…

    6c72a97
  4. serhiy-storchaka
    added a commit that references this issue on Sep 27, 2026

    gh-156261: Use the uid_t and gid_t converters in the pwd and grp modu…

    db3ffd0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirC modules in the Modules dirtopic-argument-clinictype-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.