Erlend E. Aasland
5df8b0d5c7
gh-95065: Argument Clinic: Add comment to preprocessor warning code ( #107766 )
2023-08-08 08:43:41 +00:00
Erlend E. Aasland
0db043dd5a
gh-95065: Make Argument Clinic append deprecation warnings to docstrings ( #107745 )
2023-08-08 08:41:09 +02:00
Serhiy Storchaka
0e6e32fb84
gh-86457: Fix signature for code.replace() (GH-23199)
...
Also add support of @text_signature in Argument Clinic.
2023-08-07 23:34:53 +03:00
Erlend E. Aasland
835e388915
gh-95065: Argument Clinic: Pretty-print long C strings in generated code ( #107712 )
...
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-08-07 14:33:52 +00:00
Alex Waygood
c399b5e1a5
gh-107713: Reduce usage of mocks in `test_clinic.py` ( #107714 )
2023-08-07 14:26:49 +01:00
Erlend E. Aasland
33cb0b06ef
gh-95065: Add Argument Clinic support for deprecating positional use of parameters ( #95151 )
...
It is now possible to deprecate passing parameters positionally with
Argument Clinic, using the new '* [from X.Y]' syntax.
(To be read as "keyword-only from Python version X.Y")
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-08-07 11:28:08 +00:00
Alex Waygood
ee3bf45e5e
gh-106368: Improve coverage reports for argument clinic ( #107693 )
2023-08-06 20:40:55 +01:00
Alex Waygood
6996b406bc
gh-104683: Improve consistency and test coverage of argument-clinic `__repr__` functions ( #107667 )
2023-08-05 21:58:38 +01:00
Alex Waygood
2c25bd82f4
gh-106368: Argument clinic: improve coverage for `self.valid_line()` calls ( #107641 )
2023-08-04 20:41:04 +01:00
Erlend E. Aasland
321f0f7932
gh-104683: Argument Clinic: Use CConverter.length_name where possible ( #107638 )
...
Also make it a cached property.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-04 17:49:07 +00:00
Alex Waygood
407d7fda94
gh-104146: Argument clinic: remove dead code highlighted by the `vulture` tool ( #107632 )
2023-08-04 14:56:50 +00:00
Alex Waygood
7eba274fb3
gh-104146: Argument clinic: Remove dead code flagged by mypy's `truthy-bool` check ( #107627 )
2023-08-04 13:28:13 +00:00
Erlend E. Aasland
ac7605ed19
gh-107614: Normalise Argument Clinic error messages ( #107615 )
...
- always wrap the offending line, token, or name in quotes
- in most cases, put the entire error message on one line
Added tests for uncovered branches that were touched by this PR.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-04 12:13:10 +00:00
Erlend E. Aasland
a443c310ac
gh-107609: Fix duplicate module check in Argument Clinic ( #107610 )
...
Also remove duplicate module def from _testcapi.
2023-08-04 07:28:25 +02:00
Alex Waygood
ee78d01a61
gh-104146: Argument clinic: remove unused methods and variables ( #107608 )
2023-08-04 00:17:17 +00:00
Erlend E. Aasland
1cd479c6d3
gh-104683: Rework Argument Clinic error handling ( #107551 )
...
Introduce ClinicError, and use it in fail(). The CLI runs main(),
catches ClinicError, formats the error message, prints to stderr
and exits with an error.
As a side effect, this refactor greatly improves the accuracy of
reported line numbers in case of error.
Also, adapt the test suite to work with ClinicError.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-03 00:00:06 +00:00
Erlend E. Aasland
bcdd307231
gh-104683: Make Argument Clinic template strings class level members ( #107556 )
...
The motivation for this change is to clean up the output_templates()
method a little bit, as it accounts for ~10% of the lines of code in
clinic.py; removing some clutter helps readability.
2023-08-02 21:37:36 +02:00
Erlend E. Aasland
9ff7b4af13
gh-107559: Argument Clinic: complain about non-ASCII chars in param docstrings ( #107560 )
...
Previously, only function docstrings were checked for non-ASCII characters.
Also, improve the warn() message.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-02 12:40:23 +00:00
Erlend E. Aasland
439466a02b
gh-104146: Remove dead code from Argument Clinic ( #107555 )
2023-08-02 09:22:17 +00:00
Erlend E. Aasland
b4d8897781
gh-104683: Argument Clinic: Refactor and simplify 'add docstring' states ( #107550 )
...
Introduce docstring_append() helper, and use it for both parameter and
function docstrings. Remove docstring fixup from
do_post_block_processing_cleanup(); instead, make sure no fixup is needed.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-01 23:32:27 +00:00
Alex Waygood
818c83cf81
gh-104683: Argument clinic: cleanup `DLSParser` `state_foo` methods ( #107543 )
2023-08-01 21:42:39 +01:00
Alex Waygood
030f6b1e84
gh-104683: Argument clinic: remove the `LandMine` class ( #107541 )
2023-08-01 21:10:54 +01:00
Erlend E. Aasland
49f238e78c
gh-107467: Restructure Argument Clinic command-line interface ( #107469 )
...
- Use ArgumentParser.error() to handle CLI errors
- Put the entire CLI in main()
- Rework ClinicExternalTest to call main() instead of using subprocesses
Co-authored-by: AlexWaygood <alex.waygood@gmail.com>
2023-08-01 18:24:23 +02:00
Alex Waygood
5113ed7a2b
gh-104683: Argument clinic: pass `clinic` as a parameter where possible ( #107435 )
2023-07-29 19:47:42 +01:00
Alex Waygood
6c74b2f669
gh-104683: Argument clinic: Make the `filename` parameter to `Clinic` required ( #107439 )
2023-07-29 19:46:52 +01:00
Alex Waygood
87de2fbb1e
gh-104050: Argument clinic: enable mypy's `--warn-return-any` setting ( #107405 )
2023-07-29 13:39:21 +01:00
Alex Waygood
55ed85e49c
gh-104050: Argument clinic: complete type annotations ( #107399 )
2023-07-28 21:27:21 +01:00
Alex Waygood
ecc05e23a1
gh-106368: Argument clinic: Fix minor bug in `state_modulename_name` ( #107387 )
2023-07-28 19:10:45 +01:00
Alex Waygood
c2b1689abc
gh-104683: Argument clinic: cleanup `state_modulename_name()` ( #107340 )
2023-07-27 22:51:18 +01:00
Erlend E. Aasland
2ad699002e
Docs: Argument Clinic: Restructure "Basic concepts and usage" ( #106981 )
...
Split "Basic concepts and usage" into:
- Reference
- Terminology
- CLI reference
- Background
- Basic concepts
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
2023-07-26 22:08:43 +00:00
Alex Waygood
5aa6964a5c
gh-104050: Argument clinic: Annotate `str_converter_key()` ( #107294 )
2023-07-26 21:12:18 +01:00
Alex Waygood
f9bcdf2368
gh-104050: Argument clinic: Complete `get_destination_buffer` annotations ( #107293 )
2023-07-26 21:11:15 +01:00
Alex Waygood
14d074e1fb
gh-104683: Argument Clinic: Make most arguments to `Class` and `Function` required ( #107289 )
2023-07-26 11:54:03 +01:00
Alex Waygood
c362678dd2
gh-104050: Argument clinic: improve typing around `parse_arg()` methods ( #107288 )
2023-07-26 11:51:24 +01:00
Alex Waygood
33838fedf7
gh-104050: Argument clinic: annotate `post_parsing()` and `cleanup()` ( #107225 )
2023-07-25 23:33:03 +01:00
Alex Waygood
ee9010784c
gh-104050: Argument clinic: more misc typing improvements ( #107264 )
2023-07-25 22:08:52 +01:00
Alex Waygood
d9e34db993
gh-104050: Argument clinic: more misc typing coverage improvements ( #107210 )
2023-07-25 08:49:07 +00:00
Alex Waygood
dbfe73837d
gh-104050: Argument clinic: improve typing around adding C converters ( #107209 )
2023-07-25 09:18:19 +01:00
Alex Waygood
4bbf071635
gh-104050: Argument Clinic: Annotate `CRenderData.__init__` ( #107207 )
...
Argument Clinic: Annotate `CRenderData.__init__`
2023-07-24 21:38:50 +00:00
Alex Waygood
d93fe5afe2
gh-104050: Argument clinic: misc improvements to type annotation coverage ( #107206 )
2023-07-24 21:23:58 +00:00
Alex Waygood
ac2d85a174
gh-104050: Argument clinic: annotate `format_docstring()` ( #107200 )
2023-07-24 20:29:50 +00:00
Alex Waygood
db17529f80
gh-104050: Argument Clinic: annotate `main()` ( #107192 )
2023-07-24 19:32:38 +00:00
Erlend E. Aasland
3aeffc0d8f
gh-104050: Argument Clinic: Increase typing coverage ( #107074 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-07-22 22:30:42 +00:00
Erlend E. Aasland
c5adf26b18
gh-104050: Argument Clinic: Annotate the BufferSeries class ( #106935 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-07-22 12:46:42 +02:00
Erlend E. Aasland
3372bcba98
gh-106970: Fix Argument Clinic 'destination <name> clear' command ( #106972 )
...
Add test for the 'destination <name> clear' command,
and the 'destination' directive in general.
Fix two bugs in 'destination <name> clear' command:
1. The text attribute of the allocator is called 'text', not '_text'
2. Return after processing the 'clear' command,
instead of proceeding directly to the fail().
2023-07-22 09:43:13 +02:00
Erlend E. Aasland
d81b4f8ff8
gh-104050: Argument Clinic: Annotate the IndentStack class ( #106934 )
2023-07-20 23:19:11 +00:00
Erlend E. Aasland
1d5a625eb0
gh-104050: Argument Clinic: Increase CConverter typing coverage ( #106932 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-07-20 22:45:02 +00:00
Erlend E. Aasland
42c6300d4f
gh-104050: Argument Clinic: Annotate CLanguage.render_option_group_parsing() ( #106929 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-07-20 21:33:33 +00:00
Erlend E. Aasland
00e52acebd
gh-104683: Argument Clinic: Modernise parse_special_symbol() ( #106837 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-07-17 22:37:11 +00:00
Erlend E. Aasland
036bb73656
gh-104050: Improve Argument Clinic type annotation coverage ( #106810 )
...
Add various missing annotations in the following classes:
- BlockPrinter
- CConverter
- CLanguage
- FormatCounterFormatter
- Language
- _TextAccumulator
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-07-17 13:47:08 +02:00
Erlend E. Aasland
383dcbebcd
gh-104050: Argument Clinic: Annotate Clinic.parse() ( #106760 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-07-17 00:04:10 +00:00
Erlend E. Aasland
bbf6297985
gh-104050: Argument Clinic: Annotate BlockParser ( #106750 )
2023-07-15 10:11:32 +00:00
Erlend E. Aasland
7c95345e4f
gh-104050: Argument Clinic: Annotate `output_templates()` ( #106732 )
...
Co-authored-by: AlexWaygood <alex.waygood@gmail.com>
2023-07-14 12:20:58 +00:00
Alex Waygood
128a6c1d88
gh-104683: Argument clinic: use an enum to describe the different kinds of functions ( #106721 )
...
Argument clinic: use an enum to describe the different kinds of functions
2023-07-13 22:54:05 +00:00
Erlend E. Aasland
2d43beec22
gh-104050: Argument Clinic: Annotate nested function parser_body() in the CLanguage class ( #106699 )
2023-07-12 22:49:30 +00:00
Alex Waygood
8aa4beaad0
gh-104683: Argument clinic: modernise `cpp.Monitor` ( #106698 )
2023-07-12 22:48:36 +00:00
Alex Waygood
a180e7a0df
gh-104050: Argument clinic: Annotate the `Destination` class ( #106655 )
...
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-07-12 22:33:47 +01:00
Alex Waygood
7ce3ea4906
gh-104683: Argument clinic: Minor readability improvements for `Destination.__init__` ( #106652 )
2023-07-11 23:08:28 +00:00
Alex Waygood
d0972c77aa
gh-104050: Argument Clinic: Annotate the `Block` class ( #106519 )
2023-07-11 21:21:14 +00:00
Alex Waygood
363f4f99c5
gh-104683: clinic.py: refactor `Parameter` and `Function` as dataclasses ( #106477 )
2023-07-07 13:10:07 +00:00
Alex Waygood
5548097925
gh-104683: clinic.py: refactor four simple classes as dataclasses ( #106476 )
2023-07-06 22:17:12 +01:00
Alex Waygood
d0c6ba956f
gh-104683: clinic.py: Don't needlessly reimplement `contextlib.redirect_stdout` ( #106478 )
...
clinic.py: Don't needlessly reimplement `contextlib.redirect_stdout`
2023-07-06 14:23:02 +01:00
Erlend E. Aasland
9d1d4f9c73
gh-64595: Fix regression in file write logic in Argument Clinic ( #106449 )
...
Revert the two commits that introduced the regressions:
- gh-104152
- gh-104507
2023-07-05 13:23:22 +02:00
Erlend E. Aasland
7bb9fa5ae4
gh-104050: Partially annotate Argument Clinic CLanguage class ( #106437 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-07-04 23:07:57 +00:00
Erlend E. Aasland
22087516bc
gh-104050: Annotate Argument Clinic parameter permutation helpers ( #106431 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-07-04 22:15:10 +00:00
Erlend E. Aasland
110b97c94c
gh-104050: Annotate toplevel functions in clinic.py ( #106435 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-07-04 22:13:30 +00:00
Erlend E. Aasland
8f6df5e9cb
gh-106368: Add tests for permutation helpers in Argument Clinic ( #106407 )
...
Added new test class PermutationTests()
2023-07-04 11:36:40 +00:00
Erlend E. Aasland
b24479dcba
gh-104050: Annotate more Argument Clinic DSLParser state methods ( #106376 )
...
Annotate the following methods:
- state_parameter()
- state_parameter_docstring_start()
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-07-03 22:10:46 +00:00
Erlend E. Aasland
71b40443fe
gh-104683: Modernise Argument Clinic parameter state machine ( #106362 )
...
Use enums and pattern matching to make the code more readable.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-07-03 21:16:21 +00:00
Erlend E. Aasland
2e2daac2f1
gh-104050: Add more type hints to Argument Clinic DSLParser() ( #106354 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-07-03 14:03:31 +00:00
Erlend E. Aasland
0da4c883cf
gh-106359: Fix corner case bugs in Argument Clinic converter parser ( #106361 )
...
DSLParser.parse_converter() could return unusable kwdicts in some rare cases
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-07-03 13:14:59 +00:00
Erlend E. Aasland
60e41a0cbb
gh-104146: Remove unused attr 'parameter_indent' from clinic.DLParser ( #106358 )
2023-07-03 11:00:35 +00:00
Erlend E. Aasland
18fedd04a7
gh-104050: Annotate Argument Clinic DSLParser attributes ( #106357 )
2023-07-03 10:06:54 +00:00
Erlend E. Aasland
569887aa9d
gh-104050: Add more type hints to Argument Clinic DSLParser() ( #106343 )
...
Annotate the following method signatures:
- state_dsl_start()
- state_parameter_docstring_start()
- state_parameters_start()
Inverting ignore_line() logic, add type hints (including type guard) to
it, and rename to valid_line().
2023-07-02 23:42:38 +00:00
dependabot[bot]
c336b4c14f
build(deps-dev): bump mypy from 1.3.0 to 1.4.1 in /Tools/clinic ( #106305 )
...
Bumps [mypy](https://github.com/python/mypy ) from 1.3.0 to 1.4.1.
- [Commits](https://github.com/python/mypy/compare/v1.3.0...v1.4.1 )
---
updated-dependencies:
- dependency-name: mypy
dependency-type: direct:development
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-01 09:54:32 +00:00
Victor Stinner
cbb9ba844f
gh-92536: Argument Clinic no longer emits PyUnicode_READY() ( #105208 )
...
Since Python 3.12, PyUnicode_READY() does nothing and always
returns 0.
Argument Clinic now also checks for .cpp files (PC/_wmimodule.cpp).
2023-06-02 01:31:58 +02:00
Victor Stinner
dd29ae26f8
gh-105156: Argument Clinic avoids Py_UNICODE type ( #105161 )
...
Argument Clinic now uses "const wchar_t*" type instead of
"const Py_UNICODE*" type for the "Py_UNICODE" format.
2023-05-31 17:52:33 +00:00
Alex Waygood
4b107d86f3
gh-104683: clinic.py: Modernise `parse_converter()` using pattern-matching ( #104696 )
2023-05-21 23:29:43 +00:00
Erlend E. Aasland
6ba8406cb6
gh-104050: Add more type annotations to Argument Clinic ( #104631 )
...
Annotate methods of the following classes:
- class Function
- class Parameter
- class LandMine
2023-05-21 21:24:26 +00:00
Erlend E. Aasland
bf6dd8f5fd
gh-104050: Add basic type hints to Argument Clinic clinic class ( #104705 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-05-21 20:49:34 +00:00
Erlend E. Aasland
c482e9a4e6
gh-104050: Annotate Argument Clinic return converters ( #104706 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-05-21 20:23:14 +00:00
Erlend E. Aasland
27a68be77f
gh-104050: Add basic type hints to Argument Clinic DSL parser ( #104704 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-05-20 21:55:02 +00:00
Alex Waygood
19dd5aa89a
gh-104683: Modernise Tools/clinic/ ( #104684 )
...
- Make some string interpolations more readable using f-strings or
explicit parametrisation
- Remove unneeded open() mode specifiers
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-05-20 20:16:49 +00:00
Alex Waygood
663c049ff7
gh-104683: Modernise `clinic.py` using `str.removeprefix` and `str.removesuffix` ( #104685 )
...
Both methods were new in Python 3.9.
2023-05-20 11:08:28 +00:00
Erlend E. Aasland
ae147d01a0
gh-104146: Purge dead code from Argument Clinic ( #104680 )
...
The following local variables were assigned but never used:
- line 551: result
- line 1341: groups
- line 1431: default_return_converter
- line 1529: ignore_self
- line 1809: input_checksum
- line 4224: new'
---
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-05-20 10:52:32 +00:00
Alex Waygood
02b60035ce
gh-104683: Argument clinic: use `dict` over `OrderedDict` ( #104647 )
...
For code readability. Instances of `builtins.dict` have been ordered since 3.6, and have been guaranteed by the language to be ordered since Python 3.7. Argument Clinic now requires Python 3.10+.
2023-05-20 11:24:00 +01:00
Erlend E. Aasland
94c8edabd3
gh-104050: Add more type annotations to Argument Clinic ( #104628 )
...
Annotate the following:
- methods of class Class
- methods of class Module
- methods of class PythonParser
- function compute_checksum()
- function parse_file()
- global variable unsupported_special_methods
2023-05-18 22:57:26 +00:00
Alex Waygood
1c55e8d007
gh-104050: Improve some typing around `default`s and sentinel values ( #104626 )
...
- Convert `unspecified` and `unknown` to be members of a `Sentinels` enum, rather than instances of bespoke classes.
- An enum feels more idiomatic here, and works better with type checkers.
- Convert some `==` and `!=` checks for these values to identity checks, which are more idiomatic with sentinels.
- _Don't_ do the same for `Null`, as this needs to be a distinct type due to its usage in `clinic.py`.
- Use `object` as the annotation for `default` across `clinic.py`. `default` can be literally any object, so `object` is the correct annotation here.
---
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-05-18 21:58:42 +00:00
Erlend E. Aasland
61027c0211
gh-104146: Remove unused vars from Argument Clinic ( #104627 )
...
Remove 'in_classes' and 'so_far' from DSLParser.directive_module()
2023-05-18 21:52:59 +00:00
Erlend E. Aasland
2f369cafee
gh-104050: Add type hints to Argument Clinic converter keywords ( #104588 )
...
Introduce TypeSet, and use it to annotate the 'accept' keyword of
various C converters. Also add some missing return annotations for
converter init functions.
2023-05-17 21:05:22 +00:00
Erlend E. Aasland
0afc473f50
gh-104050: Add typing to Argument Clinic converters ( #104547 )
2023-05-16 22:32:11 +00:00
Nikita Sobolev
a454a6651b
gh-104050: Add more annotations to `Tools/clinic.py` ( #104544 )
2023-05-16 17:18:28 +00:00
Erlend E. Aasland
c22fced96c
gh-104050: Don't star-import 'types' in Argument Clinic ( #104543 )
2023-05-16 12:02:18 +00:00
Erlend E. Aasland
505e2954a9
gh-104050: Add basic typing to CConverter in clinic.py ( #104538 )
2023-05-16 11:47:35 +00:00
Erlend E. Aasland
cca90b6906
gh-64595: Fix write file logic in Argument Clinic ( #104507 )
...
Check if any clinic output actually changes any of the output files
before deciding if we should touch the source file.
2023-05-16 12:25:43 +02:00
dependabot[bot]
35bf0916d9
Bump mypy from 1.2.0 to 1.3.0 in /Tools/clinic ( #104501 )
...
build(deps-dev): bump mypy from 1.2.0 to 1.3.0 in /Tools/clinic
Bumps [mypy](https://github.com/python/mypy ) from 1.2.0 to 1.3.0.
- [Commits](https://github.com/python/mypy/compare/v1.2.0...v1.3.0 )
---
updated-dependencies:
- dependency-name: mypy
dependency-type: direct:development
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-15 09:17:48 +00:00
Alex Waygood
9d41f83c58
gh-104050: Run mypy on `clinic.py` in CI ( #104421 )
...
* Add basic mypy workflow to CI
* Make the type check pass
---------
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-05-15 08:49:28 +00:00
Erlend E. Aasland
b2c1b4da19
gh-104389: Add 'unused' keyword to Argument Clinic C converters ( #104390 )
...
Use the unused keyword param in the converter to explicitly
mark an argument as unused:
/*[clinic input]
SomeBaseClass.stubmethod
flag: bool(unused=True)
[clinic start generated code]*/
2023-05-12 10:34:00 +02:00
Alex Waygood
fe694a6db6
gh-90953: Don't use deprecated AST nodes in clinic.py ( #104322 )
2023-05-09 22:16:22 +01:00
Erlend E. Aasland
ac020624b3
gh-64660: Don't hardcode Argument Clinic return converter result variable name ( #104200 )
2023-05-07 21:55:37 +00:00
Erlend E. Aasland
66558d2a16
gh-104146: Remove unused var 'parser_body_declarations' from clinic.py ( #104214 )
2023-05-05 21:35:24 +00:00
Erlend E. Aasland
45a9e3834a
gh-64595: Argument Clinic: Touch source file if any output file changed ( #104152 )
2023-05-05 12:38:38 +00:00
Erlend E. Aasland
5245cb64d9
gh-68395: Avoid naming conflicts by mangling variable names in Argument Clinic ( #104065 )
...
Add all internally used variable names to CLINIC_PREFIXED_ARGS.
2023-05-05 13:40:18 +02:00
Erlend E. Aasland
9885677b04
gh-104146: Remove unused 'second_pass_replacements' from clinic.py ( #104147 )
...
The code that manipulated 'second_pass_replacements' was removed in 2015
with commit 0759f84
(gh-67688, bpo-23500).
2023-05-04 00:11:29 +00:00
Erlend E. Aasland
2753cf2ed6
gh-101409: Improve generated clinic code for self type checks ( #101411 )
2023-01-31 21:42:03 +01:00
Nikita Sobolev
3da71ff0f2
Fix copy-paste error in `Tools/clinic.py` ( #100560 )
2022-12-28 09:57:57 +05:30
Kumar Aditya
7cf164ad5e
GH-100342: check for allocation failure in AC `*args` parsing ( #100343 )
2022-12-28 09:46:28 +05:30
Nikita Sobolev
b0ea28913e
Remove `NoneType` redefinition from `clinic.py` ( #100551 )
2022-12-27 21:41:39 +05:30
Shantanu
621a1790c4
gh-100176: remove incorrect version compatibility check from argument clinic ( #100190 )
2022-12-12 17:22:12 +05:30
colorfulappl
0da728387c
gh-64490: Fix bugs in argument clinic varargs processing ( #32092 )
2022-11-24 20:56:50 +01:00
colorfulappl
8dbe08eb7c
gh-99240: Fix double-free bug in Argument Clinic str_converter generated code (GH-99241)
...
Fix double-free bug mentioned at https://github.com/python/cpython/issues/99240 ,
by moving memory clean up out of "exit" label.
Automerge-Triggered-By: GH:erlend-aasland
2022-11-24 06:01:26 -08:00
colorfulappl
69f6cc77d0
gh-64490: Fix refcount error when arguments are packed to tuple in argument clinic ( #99233 )
2022-11-24 17:54:18 +05:30
Irit Katriel
34e6f3567e
gh-92886: [clinic.py] raise exception on invalid input instead of assertion (GH-98051)
...
Tests should pass with -O (assertions off).
Automerge-Triggered-By: GH:iritkatriel
2022-10-07 14:41:35 -07:00
Serhiy Storchaka
0ee9619a4c
gh-97728: Argument Clinic: Fix uninitialized variable in the Py_UNICODE converter (GH-97729)
...
It affects function os.system() on Windows and Windows-specific modules
winreg, _winapi, _overlapped, and _msi.
2022-10-03 10:42:54 +03:00
Erlend E. Aasland
f07adf82f3
gh-90928: Improve static initialization of keywords tuple in AC ( #95907 )
2022-08-13 12:09:40 +02:00
Eric Snow
6f6a4e6cc5
gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code (gh-95860)
...
We only statically initialize for core code and builtin modules. Extension modules still create
the tuple at runtime. We'll solve that part of interpreter isolation separately.
This change includes generated code. The non-generated changes are in:
* Tools/clinic/clinic.py
* Python/getargs.c
* Include/cpython/modsupport.h
* Makefile.pre.in (re-generate global strings after running clinic)
* very minor tweaks to Modules/_codecsmodule.c and Python/Python-tokenize.c
All other changes are generated code (clinic, global strings).
2022-08-11 15:25:49 -06:00
Serhiy Storchaka
74b5e4ce80
gh-95007: Remove the NoneType return converter (GH-95019)
...
It has confusing semantic which does not provide any benefit (the
only difference is that you should write "return Py_None" instead
of "Py_RETURN_NONE"), it is not currently used, and it is broken.
2022-07-20 08:42:02 +03:00
Erlend Egeberg Aasland
8bbd70b4d1
gh-94430: Allow params named `module` or `self` with custom C names in Argument Clinic ( #94431 )
2022-07-07 11:29:34 +02:00
Erlend Egeberg Aasland
2b8ed4d3d4
gh-94538: Fix Argument Clinic output to custom file ( #94539 )
2022-07-05 11:06:04 +02:00
Victor Stinner
47e35625ff
gh-84623: Remove unused imports ( #94132 )
2022-06-22 19:14:27 +02:00
Inada Naoki
f9c9354a7a
gh-92536: PEP 623: Remove wstr and legacy APIs from Unicode (GH-92537)
2022-05-12 14:48:38 +09:00
Erlend Egeberg Aasland
4bd07d1dbd
gh-92256: Improve Argument Clinic parser error messages ( #92268 )
...
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2022-05-10 09:23:42 +02:00
Victor Stinner
b270b82f11
gh-91320: Argument Clinic uses _PyCFunction_CAST() ( #32210 )
...
Replace "(PyCFunction)(void(*)(void))func" cast with
_PyCFunction_CAST(func).
2022-05-03 20:25:41 +02:00
Serhiy Storchaka
a055dac0b4
gh-91583: AC: Fix regression for functions with defining_class (GH-91739)
...
Argument Clinic now generates the same efficient code as before
adding the defining_class parameter.
2022-04-30 13:15:02 +03:00
Victor Stinner
042f31da55
bpo-45459: C API uses type names rather than structure names (GH-31528)
...
Thanks to the new pytypedefs.h, it becomes to use type names like
PyObject rather like structure names like "struct _object".
2022-02-24 17:51:59 +01:00
Serhiy Storchaka
d8a464ef03
Remove an outdated comment. (GH-30010)
2021-12-09 20:44:36 +02:00
Serhiy Storchaka
92bf8691fb
bpo-43413: Fix handling keyword arguments in subclasses of some buitin classes (GH-26456)
...
* Constructors of subclasses of some buitin classes (e.g. tuple, list,
frozenset) no longer accept arbitrary keyword arguments.
* Subclass of set can now define a __new__() method with additional
keyword parameters without overriding also __init__().
2021-09-12 13:27:50 +03:00
Serhiy Storchaka
3c65457156
bpo-45060: Get rid of few uses of the equality operators with None (GH-28087)
2021-08-31 16:59:52 +03:00
Dong-hee Na
24b63c695a
bpo-24234: Implement bytes.__bytes__ (GH-27901)
2021-08-23 19:01:51 +09:00
Mark Dickinson
c5c3fbe2a1
bpo-44978: allow Argument Clinic to handle __complex__ special methods (GH-27886)
2021-08-22 13:13:26 +01:00
Batuhan Taskaya
9af34c9351
bpo-20201: variadic arguments support for AC (GH-18609)
...
Implement support for `*args` in AC, and port `print()` to use it.
2021-07-16 18:43:02 +03:00
Inada Naoki
4d4be47705
Do not use Py_ssize_clean_t (GH-25940)
2021-05-08 10:17:37 +09:00
Dong-hee Na
df9ade9beb
AC: Update unsupported_special_methods (GH-24956)
2021-03-25 09:19:23 +09:00
Victor Stinner
8fba9523cf
bpo-42398: Fix "make regen-all" race condition (GH-23362)
...
Fix a race condition in "make regen-all" when make -jN option is used
to run jobs in parallel. The clinic.py script now only use atomic
write to write files. Moveover, generated files are now left
unchanged if the content does not change, to not change the file
modification time.
The "make regen-all" command runs "make clinic" and "make
regen-importlib" targets:
* "make regen-importlib" builds object files (ex: Modules/_weakref.o)
from source files (ex: Modules/_weakref.c) and clinic files (ex:
Modules/clinic/_weakref.c.h)
* "make clinic" always rewrites all clinic files
(ex: Modules/clinic/_weakref.c.h)
Since there is no dependency between "clinic" and "regen-importlib"
Makefile targets, these two targets can be run in parallel. Moreover,
half of clinic.py file writes are not atomic and so there is a race
condition when "make regen-all" runs jobs in parallel using make -jN
option (which can be passed in MAKEFLAGS environment variable).
Fix clinic.py to make all file writes atomic:
* Add write_file() function to ensure that all file writes are
atomic: write into a temporary file and then use os.replace().
* Moreover, write_file() doesn't recreate or modify the file if the
content does not change to avoid modifying the file modification
file.
* Update test_clinic to verify these assertions with a functional
test.
* Remove Clinic.force attribute which was no longer used, whereas
Clinic.verify remains useful.
2020-11-18 15:36:27 +01:00
Serhiy Storchaka
9975cc5008
bpo-41985: Add _PyLong_FileDescriptor_Converter and AC converter for "fildes". (GH-22620)
2020-10-09 23:00:45 +03:00
Victor Stinner
fabd7bb8e0
bpo-41521: Replace whitelist/blacklist with allowlist/denylist (GH-21822)
...
Automerge-Triggered-By: @tiran
2020-08-11 06:26:59 -07:00
Serhiy Storchaka
b3dd5cd4a3
bpo-36346: Undeprecate private function _PyUnicode_AsUnicode(). (GH-21336)
2020-07-05 18:53:45 +03:00
Serhiy Storchaka
349f76c6aa
bpo-36346: Prepare for removing the legacy Unicode C API (AC only). (GH-21223)
2020-06-30 09:03:15 +03:00
Serhiy Storchaka
5f4b229df7
bpo-40792: Make the result of PyNumber_Index() always having exact type int. (GH-20443)
...
Previously, the result could have been an instance of a subclass of int.
Also revert bpo-26202 and make attributes start, stop and step of the range
object having exact type int.
Add private function _PyNumber_Index() which preserves the old behavior
of PyNumber_Index() for performance to use it in the conversion functions
like PyLong_AsLong().
2020-05-28 10:33:45 +03:00
Serhiy Storchaka
578c3955e0
bpo-37999: No longer use __int__ in implicit integer conversions. (GH-15636)
...
Only __index__ should be used to make integer conversions lossless.
2020-05-26 18:43:38 +03:00
Victor Stinner
97e1568325
bpo-38787: Fix Argument Clinic defining_class_converter (GH-20074)
...
Don't hardcode defining_class parameter name to "cls":
* Define CConverter.set_template_dict(): do nothing by default
* CLanguage.render_function() now calls set_template_dict() on all
converters.
2020-05-14 00:31:31 +02:00
Petr Viktorin
e1becf46b4
bpo-38787: C API for module state access from extension methods (PEP 573) (GH-19936)
...
Module C state is now accessible from C-defined heap type methods (PEP 573).
Patch by Marcel Plch and Petr Viktorin.
Co-authored-by: Marcel Plch <mplch@redhat.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2020-05-07 15:39:59 +02:00
Serhiy Storchaka
12446e6a60
bpo-40179: Fix translation of #elif in Argument Clinic (GH-19364)
...
Co-authored-by: Ammar Askar <ammar@ammaraskar.com>
2020-04-18 17:52:48 +03:00
Dong-hee Na
9aeb0ef930
bpo-39573: Update clinic to use Py_IS_TYPE() function (GH-18507)
2020-02-14 08:50:19 +01:00
Dong-hee Na
5136e721d7
argument-clinic: Simplify multi-line string handling (GH-17852)
2020-01-06 10:46:03 +00:00
Sergey Fedoseev
a9ed91e6c2
bpo-27961: Replace PY_LONG_LONG with long long. (GH-15386)
2019-10-21 09:49:48 +03:00
Serhiy Storchaka
279f44678c
bpo-37206: Unrepresentable default values no longer represented as None. (GH-13933)
...
In ArgumentClinic, value "NULL" should now be used only for unrepresentable default values
(like in the optional third parameter of getattr). "None" should be used if None is accepted
as argument and passing None has the same effect as not passing the argument at all.
2019-09-14 12:24:05 +03:00
Rémi Lapeyre
4901fe274b
bpo-37034: Display argument name on errors with keyword arguments with Argument Clinic. (GH-13593)
2019-08-29 17:49:08 +03:00
Raymond Hettinger
aef9ad82f7
bpo-37942: Improve argument clinic float converter (GH-15470)
2019-08-24 19:10:39 -07:00
Tim Hoffmann
5df4025f42
Add description to the command line help of the argument clinic (GH-8518)
2019-06-02 17:58:10 +01:00