summaryrefslogtreecommitdiffstats
path: root/Tools/clinic
Commit message (Collapse)AuthorAgeFilesLines
* gh-128152: Argument Clinic: ignore pre-processor directives inside C ↵Erlend E. Aasland2025-01-041-0/+3
| | | | comments (#128464)
* gh-128083: Fix macro redefinition warning in clinic. (GH-127950)Peter Bierma2024-12-191-0/+3
|
* gh-127341: Argument Clinic: fix compiler warnings for getters with ↵Peter Bierma2024-11-291-7/+3
| | | | | docstrings (#127310) Co-authored-by: Erlend E. Aasland <erlend@python.org>
* gh-122943: Add the varpos parameter in _PyArg_UnpackKeywords (GH-126564)Serhiy Storchaka2024-11-081-9/+4
| | | | Remove _PyArg_UnpackKeywordsWithVararg. Add comments for integer arguments of _PyArg_UnpackKeywords.
* gh-122943: Move code generation for var-positional parameter to converters ↵Serhiy Storchaka2024-11-082-73/+91
| | | | (GH-126575)
* gh-122943: Remove the object converter for var-positional parameter (GH-126560)Serhiy Storchaka2024-11-081-4/+0
|
* gh-122943: Rework support of var-positional parameter in Argument Clinic ↵Serhiy Storchaka2024-11-075-83/+155
| | | | | | | | | | | | | | | | | | (GH-122945) Move creation of a tuple for var-positional parameter out of _PyArg_UnpackKeywordsWithVararg(). Merge _PyArg_UnpackKeywordsWithVararg() with _PyArg_UnpackKeywords(). Add a new parameter in _PyArg_UnpackKeywords(). The "parameters" and "converters" attributes of ParseArgsCodeGen no longer contain the var-positional parameter. It is now available as the "varpos" attribute. Optimize code generation for var-positional parameter and reuse the same generating code for functions with and without keyword parameters. Add special converters for var-positional parameter. "tuple" represents it as a Python tuple and "array" represents it as a continuous array of PyObject*. "object" is a temporary alias of "tuple".
* gh-90370: Argument Clinic: avoid temporary tuple creation for varargs (#126064)Sergey B Kirpichev2024-10-312-26/+24
| | | | | | | Avoid temporary tuple creation when all arguments either positional-only or vararg. Objects/setobject.c and Modules/gcmodule.c adapted. This fixes slight performance regression for set methods, introduced by gh-115112.
* CI: Bump Python to 3.13 and mypy to 1.12 in mypy workflow (#125592)Kirill Podoprigora2024-10-161-3/+1
| | | | | * Bump mypy to 1.12 & Python to 3.13 * Remove unnecessary `type: ignore`
* gh-122688: Fix support of var-positional parameter in Argument Clinic ↵Serhiy Storchaka2024-08-092-10/+12
| | | | | | | | | (GH-122689) * Parameters after the var-positional parameter are now keyword-only instead of positional-or-keyword. * Correctly calculate min_kw_only. * Raise errors for invalid combinations of the var-positional parameter with "*", "/" and deprecation markers.
* build(deps-dev): bump mypy from 1.10.1 to 1.11.1 in /Tools (#122550)dependabot[bot]2024-08-051-1/+3
| | | | | Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
* gh-113993: Allow interned strings to be mortal, and fix related issues ↵Petr Viktorin2024-06-211-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (GH-120520) * Add an InternalDocs file describing how interning should work and how to use it. * Add internal functions to *explicitly* request what kind of interning is done: - `_PyUnicode_InternMortal` - `_PyUnicode_InternImmortal` - `_PyUnicode_InternStatic` * Switch uses of `PyUnicode_InternInPlace` to those. * Disallow using `_Py_SetImmortal` on strings directly. You should use `_PyUnicode_InternImmortal` instead: - Strings should be interned before immortalization, otherwise you're possibly interning a immortalizing copy. - `_Py_SetImmortal` doesn't handle the `SSTATE_INTERNED_MORTAL` to `SSTATE_INTERNED_IMMORTAL` update, and those flags can't be changed in backports, as they are now part of public API and version-specific ABI. * Add private `_only_immortal` argument for `sys.getunicodeinternedsize`, used in refleak test machinery. * Make sure the statically allocated string singletons are unique. This means these sets are now disjoint: - `_Py_ID` - `_Py_STR` (including the empty string) - one-character latin-1 singletons Now, when you intern a singleton, that exact singleton will be interned. * Add a `_Py_LATIN1_CHR` macro, use it instead of `_Py_ID`/`_Py_STR` for one-character latin-1 singletons everywhere (including Clinic). * Intern `_Py_STR` singletons at startup. * For free-threaded builds, intern `_Py_LATIN1_CHR` singletons at startup. * Beef up the tests. Cover internal details (marked with `@cpython_only`). * Add lots of assertions Co-Authored-By: Eric Snow <ericsnowcurrently@gmail.com>
* gh-119661: Add _Py_SINGLETON() include in Argumenet Clinic (#119712)Victor Stinner2024-05-291-3/+9
| | | | | When the _Py_SINGLETON() is used, Argument Clinic now adds an explicit "pycore_runtime.h" include to get the macro. Previously, the macro may or may not be included indirectly by another include.
* gh-117557: Improve error messages when a string, bytes or bytearray of ↵Serhiy Storchaka2024-05-281-3/+22
| | | | length 1 are expected (GH-117631)
* Fix typos in comments (#119645)Xie Yanbo2024-05-281-1/+1
|
* gh-119213: Be More Careful About _PyArg_Parser.kwtuple Across Interpreters ↵Eric Snow2024-05-221-0/+2
| | | | | | | | | (gh-119331) _PyArg_Parser holds static global data generated for modules by Argument Clinic. The _PyArg_Parser.kwtuple field is a tuple object, even though it's stored within a static global. In some cases the tuple is statically allocated and thus it's okay that it gets shared by multiple interpreters. However, in other cases the tuple is set lazily, allocated from the heap using the active interprepreter at the point the tuple is needed. This is a problem once that interpreter is destroyed since _PyArg_Parser.kwtuple becomes at dangling pointer, leading to crashes. It isn't a problem if the tuple is allocated under the main interpreter, since its lifetime is bound to the lifetime of the runtime. The solution here is to temporarily switch to the main interpreter. The alternative would be to always statically allocate the tuple. This change also fixes a bug where only the most recent parser was added to the global linked list.
* gh-117613: Argument Clinic: disallow defining class parameter at module ↵neonene2024-04-171-0/+2
| | | | level (#117950)
* gh-117613: Argument Clinic: ensure that 'defining_class' params are ↵neonene2024-04-161-0/+1
| | | | positional-only (#117781)
* gh-113317: Add ParseArgsCodeGen class (#117707)Victor Stinner2024-04-114-846/+953
|
* gh-113317: Add Codegen class to Argument Clinic (#117626)Victor Stinner2024-04-117-178/+182
| | | | | | | | | | | * Move ifndef_symbols, includes and add_include() from Clinic to Codegen. Add a 'codegen' (Codegen) attribute to Clinic. * Remove libclinic.crenderdata module: move code to libclinic.codegen. * BlockPrinter.print_block(): remove unused 'limited_capi' argument. Remove also 'core_includes' parameter. * Add get_includes() methods. * Make Codegen.ifndef_symbols private. * Make Codegen.includes private. * Make CConverter.includes private.
* gh-117431: Argument Clinic: copy forced text signature when cloning (#117591)Erlend E. Aasland2024-04-102-4/+9
|
* gh-113317: Remove unused INVALID constant in Argument Clinic (#117624)Victor Stinner2024-04-081-2/+0
|
* gh-113317: Finish splitting Argument Clinic into sub-files (#117513)Victor Stinner2024-04-049-2146/+2182
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add libclinic.parser module and move the following classes and functions there: * Parser * PythonParser * create_parser_namespace() Add libclinic.dsl_parser module and move the following classes, functions and variables there: * ConverterArgs * DSLParser * FunctionNames * IndentStack * ParamState * StateKeeper * eval_ast_expr() * unsupported_special_methods Add libclinic.app module and move the Clinic class there. Add libclinic.cli module and move the following functions there: * create_cli() * main() * parse_file() * run_clinic()
* gh-113317: Argument Clinic: Add libclinic.clanguage (#117455)Victor Stinner2024-04-034-1597/+1627
| | | | | | | | | | | | | | | | | | | Add libclinic.clanguage module and move the following classes and functions there: * CLanguage * declare_parser() Add libclinic.codegen and move the following classes there: * BlockPrinter * BufferSeries * Destination Move the following functions to libclinic.function: * permute_left_option_groups() * permute_optional_groups() * permute_right_option_groups()
* gh-113317: Argument Clinic: Add libclinic.return_converters (#117451)Victor Stinner2024-04-023-181/+178
| | | | | | | | | | | | | | | | | Move the following converter classes to libclinic.return_converters: * CReturnConverter * CReturnConverterAutoRegister * Py_ssize_t_return_converter * bool_return_converter * double_return_converter * float_return_converter * int_return_converter * long_return_converter * size_t_return_converter * unsigned_int_return_converter * unsigned_long_return_converter Move also the add_c_return_converter() function there.
* gh-113317: Argument Clinic: Add libclinic.converters module (#117315)Victor Stinner2024-04-026-1212/+1255
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the following converter classes to libclinic.converters: * PyByteArrayObject_converter * PyBytesObject_converter * Py_UNICODE_converter * Py_buffer_converter * Py_complex_converter * Py_ssize_t_converter * bool_converter * byte_converter * char_converter * defining_class_converter * double_converter * fildes_converter * float_converter * int_converter * long_converter * long_long_converter * object_converter * self_converter * short_converter * size_t_converter * slice_index_converter * str_converter * unicode_converter * unsigned_char_converter * unsigned_int_converter * unsigned_long_converter * unsigned_long_long_converter * unsigned_short_converter Move also the following classes to libclinic.converters: * buffer * robuffer * rwbuffer Move the following functions to libclinic.converters: * correct_name_for_self() * r() * str_converter_key() Move Null and NULL to libclinic.utils.
* gh-113317: Change how Argument Clinic lists converters (#116853)Victor Stinner2024-03-271-32/+54
| | | | | | | | | | * Add a new create_parser_namespace() function for PythonParser to pass objects to executed code. * In run_clinic(), list converters using 'converters' and 'return_converters' dictionarties. * test_clinic: add 'object()' return converter. * Use also create_parser_namespace() in eval_ast_expr(). Co-authored-by: Erlend E. Aasland <erlend@python.org>
* gh-85283: Build pwd extension with the limited C API (#116841)Victor Stinner2024-03-151-5/+4
| | | | Argument Clinic now uses the PEP 737 "%T" format to format type name for the limited C API.
* gh-113317, AC: Add libclinic.converter module (#116821)Victor Stinner2024-03-144-601/+621
| | | | | * Move CConverter class to a new libclinic.converter module. * Move CRenderData and Include classes to a new libclinic.crenderdata module.
* gh-113317, AC: Add libclinic.block_parser module (#116819)Victor Stinner2024-03-143-336/+361
| | | | | | * Move Block and BlockParser classes to a new libclinic.block_parser module. * Move Language and PythonLanguage classes to a new libclinic.language module.
* gh-113317, AC: Add libclinic.function (#116807)Victor Stinner2024-03-144-241/+270
| | | | | | Move Module, Class, Function and Parameter classes to a new libclinic.function module. Move VersionTuple and Sentinels to libclinic.utils.
* gh-116646, AC: Always use PyObject_AsFileDescriptor() in fildes (#116806)Victor Stinner2024-03-141-10/+7
| | | | | | | The fildes converter of Argument Clinic now always call PyObject_AsFileDescriptor(), not only for the limited C API. The _PyLong_FileDescriptor_Converter() converter stays as a fallback when PyObject_AsFileDescriptor() cannot be used.
* gh-116646, AC: Add CConverter.use_converter() method (#116793)Victor Stinner2024-03-141-6/+35
| | | Only add includes when the converter is effectively used.
* gh-116646: Add limited C API support to AC fildes converter (#116769)Victor Stinner2024-03-141-12/+13
| | | Add tests on the "fildes" converter to _testclinic_limited.
* gh-113317, AC: Move warn() and fail() to libclinic.errors (#116770)Victor Stinner2024-03-143-47/+51
|
* gh-108494: Fix Argument Clinic LIMITED_CAPI_REGEX (#116610)Victor Stinner2024-03-111-2/+3
| | | Accept spaces in "# define Py_LIMITED_API 0x030d0000".
* gh-116417: Avoid PyFloat_AS_DOUBLE() in AC limited C API (#116568)Victor Stinner2024-03-101-18/+36
| | | | Argument Clinic no longer calls PyFloat_AS_DOUBLE() when the usage of the limited C API is requested.
* gh-114258: Argument Clinic: refactor getset implementation (#116170)Erlend E. Aasland2024-03-041-25/+10
| | | | | | * Move param guard to param state machine * Override return converter during parsing * Don't use a custom type slot return converter; instead special case type slot functions during generation.
* gh-116171: Argument Clinic: disallow overriding return converter for ↵Erlend E. Aasland2024-03-011-0/+2
| | | | __init__ methods (#116172)
* Remove `ConverterKeywordDict` alias in `clinic.py` (#115843)Nikita Sobolev2024-02-231-3/+1
|
* gh-113317: Argument Clinic: move C/Py identifier helpers into libclinic ↵Erlend E. Aasland2024-02-163-29/+45
| | | | (#115520)
* gh-113317: Argument Clinic: move linear_format into libclinic (#115518)Erlend E. Aasland2024-02-153-55/+62
|
* gh-113317: Argument Clinic: inline required_type_for_self_for_parser() in ↵Erlend E. Aasland2024-02-151-9/+4
| | | | | self converter (#115522) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* gh-113317: Argument Clinic: remove global clinic instance (#115517)Erlend E. Aasland2024-02-151-7/+3
|
* gh-113317: Argument Clinic: don't use global state in warn() and fail() ↵Erlend E. Aasland2024-02-151-11/+18
| | | | (#115510)
* gh-113317: Argument Clinic: don't use fail() in CLI (#115513)Erlend E. Aasland2024-02-151-2/+2
|
* gh-114258: Refactor Argument Clinic function name parser (#114930)Erlend E. Aasland2024-02-151-106/+123
| | | | | | | | | | Refactor state_modulename_name() of the parsing state machine, by adding helpers for the sections that deal with ...: 1. parsing the function name 2. normalizing "function kind" 3. dealing with cloned functions 4. resolving return converters 5. adding the function to the DSL parser
* gh-115015: Argument Clinic: fix generated code for METH_METHOD methods ↵Erlend E. Aasland2024-02-051-1/+1
| | | | without params (#115016)
* gh-115026: Argument Clinic: handle PyBuffer_FillInfo errors in generated ↵Nikita Sobolev2024-02-051-1/+3
| | | | code (#115027)
* Bump ruff to 0.2.0 (#114932)Alex Waygood2024-02-021-0/+2
|