Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 33.9k
Description
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:
classBOOL_converter(CConverter): type = 'BOOL' format_unit = 'i'classpid_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:
classBOOL_converter(int_converter): type = 'BOOL'classpid_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)