Commit Graph

3909 Commits

Author SHA1 Message Date
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
Guido van Rossum
85e5b1f5b8
gh-106812: Fix two tiny bugs in analysis.py (#107649)
This fixes two tiny defects in analysis.py that I didn't catch on time in #107564:

- `get_var_names` in `check_macro_consistency` should skip `UNUSED` names.
- Fix an occurrence of `is UNUSED` (should be `==`).
2023-08-05 04:50:36 +00: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
Guido van Rossum
400835ea16
gh-106812: Refactor cases_generator to allow uops with array stack effects (#107564)
Introducing a new file, stacking.py, that takes over several responsibilities related to symbolic evaluation of push/pop operations, with more generality.
2023-08-04 09:35:56 -07: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
Mark Shannon
2ba7c7f7b1
Add some GC stats to Py_STATS (GH-107581) 2023-08-04 10:34:23 +01: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
Irit Katriel
dd693d6320
gh-105481: simplify definition of pseudo ops in Lib/opcode.py (#107561) 2023-08-02 18:16:57 +01: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
Irit Katriel
2bd04d4234
gh-105481: combine regen-opcode-targets with regen-opcode to avoid calculating the specialized opcodes in two places (#107540) 2023-08-01 21:05:48 +01:00
Irit Katriel
6ef8f8ca88
gh-105481: the ENABLE_SPECIALIZATION flag does not need to be generated by the build script, or exposed in opcode.py (#107534) 2023-08-01 17:05:00 +00: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
Charlie Zhao
3979150a0d
gh-106263: Fix segfault in signaldict_repr in _decimal module (#106270)
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
2023-07-30 13:58:54 +05:30
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
Erlend E. Aasland
3a1d819ebc
gh-104629: Build _testclinic extension module on Windows (#104723) 2023-07-28 18:31:30 +02:00
Charlie Zhao
a43cc3fa1f
gh-106078: Isolate decimal module (#107287) 2023-07-28 11:28:14 +05:30
Alex Waygood
c2b1689abc
gh-104683: Argument clinic: cleanup state_modulename_name() (#107340) 2023-07-27 22:51:18 +01:00
Eric Snow
8bdae1424b
gh-101524: Only Use Public C-API in the _xxsubinterpreters Module (gh-107359)
The _xxsubinterpreters module should not rely on internal API.  Some of the functions it uses were recently moved there however.  Here we move them back (and expose them properly).
2023-07-27 15:30:16 -06:00
Eric Snow
b72947a8d2
gh-106931: Intern Statically Allocated Strings Globally (gh-107272)
We tried this before with a dict and for all interned strings.  That ran into problems due to interpreter isolation.  However, exclusively using a per-interpreter cache caused some inconsistency that can eliminate the benefit of interning.  Here we circle back to using a global cache, but only for statically allocated strings.  We also use a more-basic _Py_hashtable_t for that global cache instead of a dict.

Ideally we would only have the global cache, but the optional isolation of each interpreter's allocator means that a non-static string object must not outlive its interpreter.  Thus we would have to store a copy of each such interned string in the global cache, tied to the main interpreter.
2023-07-27 13:56:59 -06:00
Irit Katriel
d77d973335
gh-105481: remove dependency of _inline_cache_entries on opname (#107339) 2023-07-27 14:15:25 +01:00
Kumar Aditya
71b3eda02c
remove outdated _asyncio globals from globals-to-fix.tsv (#107334) 2023-07-27 07:24:44 +00: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
Pablo Galindo Salgado
da8f87b7ea
gh-107015: Remove async_hacks from the tokenizer (#107018) 2023-07-26 16:34: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