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 — Fix forced arg format in AC-processed modules with custom converters · Issue #94512 · python/cpython

Fix forced arg format in AC-processed modules with custom converters #94512

New issue
Copy link
New issue
Copy link
Open
Open
Fix forced arg format in AC-processed modules with custom converters#94512
Copy link
Labels
topic-argument-clinictype-featureA feature request or enhancementA feature request or enhancement

Description

@arhadthedev
arhadthedev
opened on Jul 2, 2022
Issue body actions

There are custom Argument Clinic converters that define format_unit but omit parse_arg. As a result, generation of positional argument parsers is forced to back up from the fastest possible _PyArg_CheckPositional to slower _PyArg_ParseStack-based format strings.

Here is a list of such classes (and fixing PRs except complex cases):

  • Modules\_multiprocessing\multiprocessing.c (gh-94512: Fix forced arg format in AC-processed multiprocessing #94517)

    • HANDLE_converter
  • Modules\_multiprocessing\semaphore.c

    • SEM_HANDLE_converter
  • Modules\overlapped.c (gh-94512: Fix forced arg format in AC-processed overlapped #94516)

    • OVERLAPPED_converter
    • HANDLE_converter
    • ULONG_PTR_converter
    • DWORD_converter
    • BOOL_converter
  • Modules\posixmodule.c (gh-94512: Fix forced arg format in AC-processed posixmodule.c #122516)

    • pid_t_converter
    • idtype_t_converter
    • id_t_converter
    • intptr_t_converter
    • Py_off_t_converter
  • Modules\resource.c (gh-94512: Fix forced arg format in AC-processed resource #94515)

    • pid_t_converter
  • PC\msvcrtmodule.c (gh-94512: Fix forced arg format in AC-processed msvcrtmodule #94514)

    • HANDLE_converter
  • PC\winreg.c (gh-94512: Fix forced arg format in AC-processed winreg #94513)

    • REGSAM_converter
    • DWORD_converter
    • HKEY_converter

An example of such a converter:

class BOOL_converter(CConverter):
    type = 'BOOL'
    format_unit = 'i'

class pid_t_converter(CConverter):
    type = 'pid_t'
    format_unit = '" _Py_PARSE_PID "'

I'm going to teach all of them about low-level generation by replacing manual format_unit definitions with:

  • inheritance from a corresponding builtin converter where possible
  • and custom parse_args in other places.

For the example it gives:

class BOOL_converter(int_converter):
    type = 'BOOL'

class pid_t_converter(CConverter):
    type = 'pid_t'
    # Left as a backup for potential complex cases
    format_unit = '" _Py_PARSE_PID "'

    def parse_arg(self, argname, displayname):
        return """
            {paramname} = PyLong_AsPid({argname});
            if ({paramname} == -1 && PyErr_Occurred()) {{{{
                goto exit;
            }}}}
            """.format(argname=argname, paramname=self.parser_name)

Activity

  1. arhadthedev
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Jul 2, 2022
  2. AlexWaygood
    added
    topic-argument-clinic
    on Jul 3, 2022
  3. zooba
    added 3 commits that reference this issue on Jul 4, 2022

    gh-94512: Fix forced arg format in AC-processed msvcrtmodule (GH-94514)

    21f6b4d

    gh-94512: Fix forced arg format in AC-processed winreg (GH-94513)

    9b50f76

    gh-94512: Fix forced arg format in AC-processed multiprocessing (GH-9…

    670f7f1
  4. zooba
    added 2 commits that reference this issue on Jul 28, 2022

    gh-94512: Fix forced arg format in AC-processed overlapped (GH-94516)

    26d4af0

    gh-94512: Fix forced arg format in AC-processed resource (GH-94515)

    a739ee4
  5. erlend-aasland
    added a commit that references this issue on Oct 26, 2024

    gh-94512: Fix forced arg format in posixmodule.c clinic code (#122516)

    f6cc7c8
  6. ebonnal
    added a commit that references this issue on Jan 12, 2025

    pythongh-94512: Fix forced arg format in posixmodule.c clinic code (p…

    5228f89
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

    topic-argument-clinictype-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — 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.