summaryrefslogtreecommitdiffstats
path: root/Tools/clinic/libclinic
Commit message (Collapse)AuthorAgeFilesLines
* [3.13] gh-113993: Allow interned strings to be mortal, and fix related ↵Petr Viktorin2024-06-241-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | issues (GH-120520) (GH-120945) * 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>
* [3.13] gh-119661: Add _Py_SINGLETON() include in Argumenet Clinic (#119712) ↵Victor Stinner2024-05-291-3/+9
| | | | | | | | | | | (#119716) gh-119661: Add _Py_SINGLETON() include in Argumenet Clinic (#119712) 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. (cherry picked from commit 7ca74a760a5d3cdf48159f003d4db7c2778e9261)
* [3.13] gh-119213: Be More Careful About _PyArg_Parser.kwtuple Across ↵Miss Islington (bot)2024-05-221-0/+2
| | | | | | | | | | | | | Interpreters (gh-119331) (gh-119410) _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. (cherry picked from commit 81865002aee8eaaeb3c7e402f86183afa6de77bf) Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
* 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-048-5/+2181
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-033-0/+1622
| | | | | | | | | | | | | | | | | | | 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-022-1/+175
| | | | | | | | | | | | | | | | | 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-025-9/+1250
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-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-143-1/+617
| | | | | * 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-142-0/+359
| | | | | | * 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-143-1/+262
| | | | | | Move Module, Class, Function and Parameter classes to a new libclinic.function module. Move VersionTuple and Sentinels to libclinic.utils.
* gh-113317, AC: Move warn() and fail() to libclinic.errors (#116770)Victor Stinner2024-03-142-0/+50
|
* gh-113317: Argument Clinic: move C/Py identifier helpers into libclinic ↵Erlend E. Aasland2024-02-162-0/+41
| | | | (#115520)
* gh-113317: Argument Clinic: move linear_format into libclinic (#115518)Erlend E. Aasland2024-02-152-0/+52
|
* gh-113317: Move FormatCounterFormatter into libclinic (#114066)Erlend E. Aasland2024-01-142-5/+30
|
* gh-113317: Move global utility functions into libclinic (#113986)Erlend E. Aasland2024-01-142-0/+55
| | | | | | | | Establish Tools/clinic/libclinic/utils.py and move the following functions over there: - compute_checksum() - create_regex() - write_file()
* gh-113299: Move cpp.py into libclinic (#113526)Erlend E. Aasland2023-12-271-0/+194
|
* gh-113317: Rework Argument Clinic cpp.py error handling (#113525)Erlend E. Aasland2023-12-272-0/+32
| | | | | | | | Rework error handling in the C preprocessor helper. Instead of monkey- patching the cpp.Monitor.fail() method from within clinic.py, rewrite cpp.py to use a subclass of the ClinicError exception. As a side-effect, ClinicError is moved into Tools/clinic/libclinic/errors.py. Yak-shaving in preparation for putting cpp.py into libclinic.
* gh-113317: Move more formatting helpers into libclinic (#113438)Erlend E. Aasland2023-12-232-7/+94
| | | | | | | | | Move the following global helpers into libclinic: - format_escape() - normalize_snippet() - wrap_declarations() Also move strip_leading_and_trailing_blank_lines() and make it internal to libclinic.
* gh-113317: Clean up Argument Clinic global namespace (#113414)Erlend E. Aasland2023-12-232-0/+132
Split up clinic.py by establishing libclinic as a support package for Argument Clinic. Get rid of clinic.py globals by either making them class members, or by putting them into libclinic. - Move INCLUDE_COMMENT_COLUMN to BlockPrinter - Move NO_VARARG to CLanguage - Move formatting helpers to libclinic - Move some constants to libclinic (and annotate them as Final)