Commit Graph

4365 Commits

Author SHA1 Message Date
Mark Shannon 70d378cdaa
GH-111485: Break up instructions with unused cache entries into component micro-ops (GH-113169) 2023-12-18 13:16:45 +00:00
Mark Shannon 771903596b
GH-111485: Test the new cases generator (GH-113252) 2023-12-18 11:14:40 +00:00
Stéphane Bidoul 4a24bf9a13
gh-113246: Updated bundled pip to 23.3.2 (gh-113249)
Updated bundled pip to 23.3.2
2023-12-18 10:21:46 +00:00
Mark Shannon e24eccbc1c
GH-111485: Sort metadata tables for easier checking of future diffs (GH-113101) 2023-12-14 16:41:52 +00:00
Serhiy Storchaka 29f7eb4859
gh-59616: Support os.chmod(follow_symlinks=True) and os.lchmod() on Windows (GH-113049) 2023-12-14 13:28:37 +02:00
Steve Dower 79dad03747
gh-111650: Ensure pyconfig.h includes Py_GIL_DISABLED on Windows (GH-112778) 2023-12-13 15:38:45 +00:00
Donghee Na 498a096a51
gh-112205: Support `@setter` annotation from AC (gh-112922)
---------

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-12-13 14:00:34 +00:00
Mark Shannon 9263173280
Fix whitespace in generated code 2023-12-13 12:31:41 +00:00
Guido van Rossum 7316dfb0eb
gh-112320: Implement on-trace confidence tracking for branches (#112321)
We track the confidence as a scaled int.
2023-12-12 21:43:08 +00:00
Eric Snow a49b427b02
gh-76785: More Fixes for test.support.interpreters (gh-113012)
This brings the module (along with the associated extension modules) mostly in sync with PEP 734.  There are only a few small things to wrap up.
2023-12-12 17:43:30 +00:00
Eric Snow 86a77f4e1a
gh-76785: Fixes for test.support.interpreters (gh-112982)
This involves a number of changes for PEP 734.
2023-12-12 08:24:31 -07:00
Mark Shannon 0c55f27060
GH-111485: Factor out tier 2 code generation from the rest of the interpreter code generator (GH-112968) 2023-12-12 12:12:17 +00:00
Mark Shannon c27e9d5d17
GH-111485: Factor out generation of uop IDs from cases generator. (GH-112877) 2023-12-11 14:14:36 +00:00
Brad Larsen eb27c9a99e
Add a fuzzer for `Py_CompileStringExFlags` (#111721) 2023-12-10 12:16:15 -05:00
Jelle Zijlstra 1f9cd3c1e5
Argument Clinic: fix bare "type" in annotations (#112915)
Bare "type" in annotations should be equivalent to "type[Any]"; see
https://discuss.python.org/t/inconsistencies-between-type-and-type/37404
and python/mypy#16366. It's better to use "type[object]", which is
safer and unambiguous.
2023-12-10 15:30:02 +00:00
Mark Shannon aefdebdef1
GH-111485: Factor out opcode ID generator from the main cases generator. (GH-112831) 2023-12-08 11:48:30 +00:00
Seth Michael Larson 21221c398f
gh-112302: Add Software Bill-of-Materials (SBOM) tracking for dependencies (#112303) 2023-12-07 18:01:58 +02:00
Mark Shannon b449415b2f
GH-111485: Separate out parsing, analysis and code-gen phases of tier 1 code generator (GH-112299) 2023-12-07 12:49:40 +00:00
Victor Stinner d9e444dbb8
gh-106560: Fix redundant declarations in Python/frozen.c (#112612)
Avoid duplicated declarations of "extern" functions in
Python/frozen.c.

Compiler warnings seen by building Python with gcc -Wredundant-decls.
2023-12-03 12:18:24 +01:00
dependabot[bot] 847e4fe0e8
build(deps): bump hypothesis from 6.88.1 to 6.91.0 in /Tools (#112580)
Bumps [hypothesis](https://github.com/HypothesisWorks/hypothesis) from 6.88.1 to 6.91.0.
- [Release notes](https://github.com/HypothesisWorks/hypothesis/releases)
- [Commits](https://github.com/HypothesisWorks/hypothesis/compare/hypothesis-python-6.88.1...hypothesis-python-6.91.0)

---
updated-dependencies:
- dependency-name: hypothesis
  dependency-type: direct:production
  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-12-01 11:17:24 +00:00
Yang Hau 707c37e373
Fix typos in variable names, function names, and comments (GH-101868) 2023-12-01 09:37:40 +00:00
dependabot[bot] 467e3f9417
build(deps-dev): bump types-setuptools from 68.2.0.0 to 69.0.0.0 in /Tools (#112582)
build(deps-dev): bump types-setuptools in /Tools

Bumps [types-setuptools](https://github.com/python/typeshed) from 68.2.0.0 to 69.0.0.0.
- [Commits](https://github.com/python/typeshed/commits)

---
updated-dependencies:
- dependency-name: types-setuptools
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-01 09:29:04 +00:00
dependabot[bot] 19a86148e6
build(deps-dev): bump mypy from 1.7.0 to 1.7.1 in /Tools (#112581)
Bumps [mypy](https://github.com/python/mypy) from 1.7.0 to 1.7.1.
- [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md)
- [Commits](https://github.com/python/mypy/compare/v1.7.0...v1.7.1)

---
updated-dependencies:
- dependency-name: mypy
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-01 09:21:45 +00:00
Brett Cannon 482b0ee8f6
Clarify that WASI tool requirements are included in the devcontainer (GH-112561) 2023-11-30 13:01:07 -08:00
Irit Katriel 07ebd46f9e
gh-112519: Make it possible to specify instruction flags for pseudo instructions in bytecodes.c (#112520) 2023-11-30 11:03:30 +00:00
Donghee Na 7eeea13403
gh-112205: Support @getter annotation from AC (gh-112396) 2023-11-30 19:40:53 +09:00
Brett Cannon 37589d76bb
GH-103065, GH-106704, GH-105253: Provide a `Tools/wasm/wasi.py` script to simplify doing a WASI build (GH-112473) 2023-11-29 16:18:25 -08:00
Donghee Na 4ec849bba8
gh-112213: Add missing declaration of target_critical_section (gh-112374)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-11-25 00:58:39 +09:00
Mark Shannon 1619f4350e
GH-111485: Sort cases in the case generator output (GH-112315) 2023-11-22 15:19:50 +00:00
Guido van Rossum 8deb8bc2e5
gh-112287: Speed up Tier 2 (uop) interpreter a little (#112286)
This makes the Tier 2 interpreter a little faster.
I calculated by about 3%,
though I hesitate to claim an exact number.

This starts by doubling the trace size limit (to 512),
making it more likely that loops fit in a trace.

The rest of the approach is to only load
`oparg` and `operand` in cases that use them.
The code generator know when these are used.

For `oparg`, it will conditionally emit
```
oparg = CURRENT_OPARG();
```
at the top of the case block.
(The `oparg` variable may be referenced multiple times
by the instructions code block, so it must be in a variable.)

For `operand`, it will use `CURRENT_OPERAND()` directly
instead of referencing the `operand` variable,
which no longer exists.
(There is only one place where this will be used.)
2023-11-20 11:25:32 -08:00
Brett Cannon 56e59a49ae
GH-111807: Lower the parser stack depth under WASI debug builds (#112225) 2023-11-20 13:27:33 +00:00
Donghee Na b8c952af72
gh-111903: Update AC to support "pycore_critical_section.h" header (gh-112251) 2023-11-19 10:13:58 +09:00
Donghee Na e52cc80f7f
gh-112213: Add @critical_section target directive to Argument Clinic (gh-112232)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-11-19 08:05:49 +09:00
Guido van Rossum eb3c94ea66
gh-110319: Assert type_version != 0 before using it (#112226)
- Ensure that `assert(type_version != 0);` always comes *before* using `type_version`

Also:
- In cases_generator, rename `-v` to from `--verbose` to `--viable`
2023-11-17 20:58:13 -08:00
Guido van Rossum da314f7c8d
A few more cases_generator cleanups (#112220) 2023-11-17 22:36:37 +00:00
Guido van Rossum be0bd54c6b
gh-106529: Cleanups split off gh-112134 (#112214)
- Double max trace size to 256
- Add a dependency on executor_cases.c.h for ceval.o
- Mark `_SPECIALIZE_UNPACK_SEQUENCE` as `TIER_ONE_ONLY`
- Add debug output back showing the optimized trace
- Bunch of cleanups to Tools/cases_generator/
2023-11-17 11:49:42 -08:00
Nikita Sobolev 762eb58220
Remove `imp_dummy_def` from `Tools/c-analyzer/cpython/ignored.tsv` (gh-112122)
It was removed in 3.12, no need to keep the ignore.
2023-11-16 12:21:23 -07:00
Victor Stinner d9fd33a869
gh-112088: Run autoreconf in GHA check_generated_files (#112090)
The "Check if generated files are up to date" job of GitHub Actions
now runs the "autoreconf -ivf -Werror" command instead of the "make
regen-configure" command to avoid depending on the external quay.io
server.

Add Tools/build/regen-configure.sh script to regenerate the configure
with an Ubuntu container image. The
"quay.io/tiran/cpython_autoconf:271" container image
(https://github.com/tiran/cpython_autoconf) is no longer used.
2023-11-15 21:47:14 +01:00
Mark Shannon 4bbb367ba6
GH-111848: Set the IP when de-optimizing (GH-112065)
* Replace jumps with deopts in tier 2

* Fewer special cases of uop names

* Add target field to uop IR

* Remove more redundant SET_IP and _CHECK_VALIDITY micro-ops

* Extend whitelist of non-escaping API functions.
2023-11-15 15:48:58 +00:00
Sam Gross 324531df90
gh-111903: Add `@critical_section` directive to Argument Clinic. (#111904)
The `@critical_section` directive instructs Argument Clinic to generate calls
to `Py_BEGIN_CRITICAL_SECTION()` and `Py_END_CRITICAL_SECTION()` around the
bound function. In `--disable-gil` builds, these calls will lock and unlock
the `self` object. They are no-ops in the default build.

This is used in one place (`_io._Buffered.close`) as a demonstration.
Subsequent PRs will use it more widely in the `_io.Buffered` bindings.
2023-11-14 10:47:46 +00:00
Brandt Bucher 31ad7e061e
GH-111520: Add back the operand local (GH-111813) 2023-11-13 17:27:19 -08:00
Alex Waygood 2e7f070080
Bump mypy to 1.7.0 (#111961) 2023-11-10 16:00:50 +00:00
Mark Shannon 25c4956488
GH-109369: Exit tier 2 if executor is invalid (GH-111657) 2023-11-09 11:19:51 +00:00
Mark Shannon 06efb60264
GH-111848: Tidy up tier 2 handling of FOR_ITER specialization by using DEOPT_IF instead of jumps. (GH-111849) 2023-11-08 13:31:55 +00:00
Victor Stinner 11e83488c5
gh-111089: Revert PyUnicode_AsUTF8() changes (#111833)
* Revert "gh-111089: Use PyUnicode_AsUTF8() in Argument Clinic (#111585)"

This reverts commit d9b606b3d0.

* Revert "gh-111089: Use PyUnicode_AsUTF8() in getargs.c (#111620)"

This reverts commit cde1071b2a.

* Revert "gh-111089: PyUnicode_AsUTF8() now raises on embedded NUL (#111091)"

This reverts commit d731579bfb.

* Revert "gh-111089: Add PyUnicode_AsUTF8() to the limited C API (#111121)"

This reverts commit d8f32be5b6.

* Revert "gh-111089: Use PyUnicode_AsUTF8() in sqlite3 (#111122)"

This reverts commit 37e4e20eaa.
2023-11-07 22:36:13 +00:00
Mark Shannon 931f4438c9
GH-111485: Allow arbitrary annotations on instructions and micro-ops. (GH-111697) 2023-11-07 09:42:39 +00:00
CF Bolz-Tereick 9573d14215
gh-96954: use a directed acyclic word graph for storing the unicodedata codepoint names (#97906)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
2023-11-04 15:56:58 +01:00
Brad Larsen f21b23058e
Add a fuzz target for `_elementtree.XMLParser._parse_whole` (#111477)
* Add a fuzzer for `_elementtree.XMLParser._parse_whole`
2023-11-03 14:01:56 -07:00
dependabot[bot] 7215f173f5
build(deps): bump hypothesis from 6.87.1 to 6.88.1 in /Tools (#111596)
Bumps [hypothesis](https://github.com/HypothesisWorks/hypothesis) from 6.87.1 to 6.88.1.
- [Release notes](https://github.com/HypothesisWorks/hypothesis/releases)
- [Commits](https://github.com/HypothesisWorks/hypothesis/compare/hypothesis-python-6.87.1...hypothesis-python-6.88.1)

---
updated-dependencies:
- dependency-name: hypothesis
  dependency-type: direct:production
  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-11-02 10:53:40 +00:00
Guido van Rossum 7e135a48d6
gh-111520: Integrate the Tier 2 interpreter in the Tier 1 interpreter (#111428)
- There is no longer a separate Python/executor.c file.
- Conventions in Python/bytecodes.c are slightly different -- don't use `goto error`,
  you must use `GOTO_ERROR(error)` (same for others like `unused_local_error`).
- The `TIER_ONE` and `TIER_TWO` symbols are only valid in the generated (.c.h) files.
- In Lib/test/support/__init__.py, `Py_C_RECURSION_LIMIT` is imported from `_testcapi`.
- On Windows, in debug mode, stack allocation grows from 8MiB to 12MiB.
- **Beware!** This changes the env vars to enable uops and their debugging
  to `PYTHON_UOPS` and `PYTHON_LLTRACE`.
2023-11-01 13:13:02 -07:00
Victor Stinner d9b606b3d0
gh-111089: Use PyUnicode_AsUTF8() in Argument Clinic (#111585)
Replace PyUnicode_AsUTF8AndSize() with PyUnicode_AsUTF8() to remove
the explicit check for embedded null characters.

The change avoids to have to include explicitly <string.h> to get the
strlen() function when using a recent version of the limited C API.
2023-11-01 16:34:42 +01:00
Mark Shannon b14e882428
GH-111485: Use micro-ops to split specialization code from base action (GH-111561) 2023-11-01 10:53:27 +00:00
Mark Shannon 2904d99839
GH-111485: Remove some special cases from the code generator and bytecodes.c (GH-111540) 2023-10-31 13:21:07 +00:00
Mark Shannon d27acd4461
GH-111485: Increment `next_instr` consistently at the start of the instruction. (GH-111486) 2023-10-31 10:09:54 +00:00
Michael Droettboom 9495bcaf59
gh-111277: In summarize_stats.py, don't fail fast on invalid ratios (#111278) 2023-10-30 17:10:07 -07:00
Michael Droettboom 84b4533e84
gh-109329: Count tier2 opcode misses (#110561)
This keeps a separate 'miss' counter for each micro-opcode, incremented whenever a guard uop takes a deoptimization side exit.
2023-10-30 17:02:45 -07:00
Riccardo Ghetta 8eaa206fec
gh-109515: When generating deep frozen modules on Windows, use a list file instead of arguments (GH-109516) 2023-10-30 16:14:26 +00:00
Sam Gross 6dfb8fe023
gh-110481: Implement biased reference counting (gh-110764) 2023-10-30 16:06:09 +00:00
Dino Viehland 05f2f0ac92
gh-90815: Add mimalloc memory allocator (#109914)
* Add mimalloc v2.12

Modified src/alloc.c to remove include of alloc-override.c and not
compile new handler.

Did not include the following files:

 - include/mimalloc-new-delete.h
 - include/mimalloc-override.h
 - src/alloc-override-osx.c
 - src/alloc-override.c
 - src/static.c
 - src/region.c

mimalloc is thread safe and shares a single heap across all runtimes,
therefore finalization and getting global allocated blocks across all
runtimes is different.

* mimalloc: minimal changes for use in Python:

 - remove debug spam for freeing large allocations
 - use same bytes (0xDD) for freed allocations in CPython and mimalloc
   This is important for the test_capi debug memory tests

* Don't export mimalloc symbol in libpython.
* Enable mimalloc as Python allocator option.
* Add mimalloc MIT license.
* Log mimalloc in Lib/test/pythoninfo.py.
* Document new mimalloc support.
* Use macro defs for exports as done in:
  https://github.com/python/cpython/pull/31164/

Co-authored-by: Sam Gross <colesbury@gmail.com>
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-30 15:43:11 +00:00
Savannah Ostrowski 4a929d432b
GH-111339: Fix initialization and finalization of static optimizer types (GH-111430) 2023-10-29 13:53:25 -07:00
Irit Katriel 67a91f78e4
gh-109094: replace frame->prev_instr by frame->instr_ptr (#109095) 2023-10-26 13:43:10 +00:00
Mark Shannon b0699aa544
GH-111213: Fix a few broken stats (GH-111216) 2023-10-26 11:33:12 +01:00
Artyom Romanov 0d1cbff833
Bump test deps: `ruff` and `mypy` (#111288) 2023-10-25 01:05:37 -07:00
Michael Droettboom 81eba76450
gh-110019: Refactor summarize_stats (GH-110398) 2023-10-24 09:57:39 +01:00
Nikita Sobolev 4fbf20605b
gh-110572: Remove `test_*` from `_testcapi/getargs.c` (GH-111214) 2023-10-24 08:50:11 +03:00
Furkan Onder 32c37fe1ba
gh-67565: Remove redundant C-contiguity checks (GH-105521)
Co-authored-by: Stefan Krah <skrah@bytereef.org>
2023-10-23 12:54:46 +03:00
Victor Stinner 0937b11b89
gh-110964: clinic: refactor output_templates() (#110982) 2023-10-20 23:42:02 +02:00
Victor Stinner be5e8a0103
gh-110964: Remove private _PyArg functions (#110966)
Move the following private functions and structures to
pycore_modsupport.h internal C API:

* _PyArg_BadArgument()
* _PyArg_CheckPositional()
* _PyArg_NoKeywords()
* _PyArg_NoPositional()
* _PyArg_ParseStack()
* _PyArg_ParseStackAndKeywords()
* _PyArg_Parser structure
* _PyArg_UnpackKeywords()
* _PyArg_UnpackKeywordsWithVararg()
* _PyArg_UnpackStack()
* _Py_ANY_VARARGS()

Changes:

* Python/getargs.h now includes pycore_modsupport.h to export
  functions.
* clinic.py now adds pycore_modsupport.h when one of these functions
  is used.
* Add pycore_modsupport.h includes when a C extension uses one of
  these functions.
* Define Py_BUILD_CORE_MODULE in C extensions which now include
  directly or indirectly (via code generated by Argument Clinic)
  pycore_modsupport.h:

  * _csv
  * _curses_panel
  * _dbm
  * _gdbm
  * _multiprocessing.posixshmem
  * _sqlite.row
  * _statistics
  * grp
  * resource
  * syslog

* _testcapi: bad_get() no longer uses METH_FASTCALL calling
  convention but METH_VARARGS. Replace _PyArg_UnpackStack() with
  PyArg_ParseTuple().
* _testcapi: add PYTESTCAPI_NEED_INTERNAL_API macro which is defined
  by _testcapi sub-modules which need the internal C API
  (pycore_modsupport.h): exceptions.c, float.c, vectorcall.c,
  watchers.c.
* Remove Include/cpython/modsupport.h header file.
  Include/modsupport.h no longer includes the removed header file.
* Fix mypy clinic.py
2023-10-17 14:30:31 +02:00
Victor Stinner 054f496bd4
gh-85283: Fix Argument Clinic for md5 extension (#110976)
Limited C API supports the defining class under some conditions.
2023-10-17 13:46:16 +02:00
Victor Stinner 4dba0a6d87
gh-85283: Build md5 extension with limited C API (#110967)
* Replace _Py_strhex() with few lines of code.
* Replace _PyType_GetModuleState() with PyType_GetModuleState().
* Fix make check-c-globals.
2023-10-17 10:57:41 +00:00
Nikita Sobolev b75b1f389f
Bump test deps: `ruff` and `pre-commit-hooks` (#110972) 2023-10-17 10:32:29 +00:00
Nikita Sobolev bad7a35055
gh-110907: AC: Disallow using `*` with vararg (#110908) 2023-10-16 15:26:11 +01:00
Pablo Galindo Salgado 8316769d83
gh-110805: Fix test_peg_generator after the change in the parser for REPL tracebacks (#110814)
Fix test_peg_generator after the change in the parser for REPL tracebacks
2023-10-13 13:04:23 +02:00
Lysandros Nikolaou 898f531996
gh-106212: Raise when using c-analyzer with clang on darwin (#110757) 2023-10-13 10:52:30 +02:00
Mark Shannon 19b7ead5eb
GH-109214: Convert _SAVE_CURRENT_IP to _SET_IP in tier 2 trace creation. (GH-110755) 2023-10-12 10:34:32 +01:00
Erlend E. Aasland ec5622d197
gh-71587: Establish global state in `_datetime` (#110475)
* Use explicit initialiser for m_base
* Add module state stub; establish global state on stack
* Put conversion factors in state struct
* Move PyDateTime_TimeZone_UTC to state
* Move PyDateTime_Epoch to state struct
* Fix ref leaks in and clean up initialisation
2023-10-12 10:28:10 +02:00
Lysandros Nikolaou 17d65547df
gh-104169: Fix test_peg_generator after tokenizer refactoring (#110727)
* Fix test_peg_generator after tokenizer refactoring
* Remove references to tokenizer.c in comments etc.
2023-10-12 09:34:35 +02:00
Hugo van Kemenade de956b263b
gh-109408: Revert pre-commit whitespace checks pending portable solution (#110726) 2023-10-11 16:12:28 +00:00
Lysandros Nikolaou 01481f2dc1
gh-104169: Refactor tokenizer into lexer and wrappers (#110684)
* The lexer, which include the actual lexeme producing logic, goes into
  the `lexer` directory.
* The wrappers, one wrapper per input mode (file, string, utf-8, and
  readline), go into the `tokenizer` directory and include logic for
  creating a lexer instance and managing the buffer for different modes.
---------

Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2023-10-11 15:14:44 +00:00
Adam Turner f5edb56328
GH-109408: Move the C file whitespace check from patchcheck to pre-commit (#109890)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-10-10 07:40:08 -06:00
Alex Waygood fc811c8d20
gh-110558: Enable ruff's pyupgrade rules when running on Argument Clinic (#110603) 2023-10-10 09:35:36 +00:00
Adam Turner 08ec4a1dbf
GH-109408: Move the Python file whitespace check from patchcheck to pre-commit (#109891)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-10-10 09:17:53 +00:00
Hugo van Kemenade 7426ed0347
gh-109408: Add the docs whitespace check from patchcheck to pre-commit (#109854)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2023-10-10 08:11:51 +00:00
Alex Waygood 7b2764e798
gh-110558: Run ruff on Argument Clinic in CI (#110559) 2023-10-10 07:52:39 +00:00
Ashish Shirodkar 0050670d76
gh-106765: Updates Windows installer build instructions to clarify system requirements (GH-110566) 2023-10-09 22:15:19 +01:00
Charlie Zhao de1052245f
gh-106078: Suppress the warning caused by multi-phase initialization of `decimal` (#107524) 2023-10-07 00:15:19 +01:00
Victor Stinner a4baa9e8ac
gh-103053: Fix test_tools.test_freeze on FreeBSD (#110451)
Fix test_tools.test_freeze on FreeBSD: run "make distclean" instead
of "make clean" in the copied source directory to remove also the
"python" program.

Other test_freeze changes:

* Log executed commands and directories, and the current directory.
* No longer uses make -C option to change the directory, instead use
  subprocess cwd parameter.
2023-10-06 03:08:34 +02:00
Carl Meyer 3c0f65ebce
gh-109287: fix overrides in cases generator (#110419) 2023-10-05 15:05:29 -07:00
Michael Droettboom 9eb2489266
gh-109329: Add stat for "trace too short" (GH-110402) 2023-10-05 16:12:06 +01:00
Sam Gross cf6f23b0e3
gh-88402: Add new sysconfig variables on Windows (GH-110049)
Co-authored-by: Filipe Laíns <filipe.lains@gmail.com>
2023-10-04 22:50:29 +00:00
Michael Droettboom e561e98058
GH-109329: Add tier 2 stats (GH-109913) 2023-10-04 14:52:28 -07:00
Guido van Rossum 7c149a76b2
gh-104909: Split more LOAD_ATTR specializations (GH-110317)
* Split LOAD_ATTR_MODULE

* Split LOAD_ATTR_WITH_HINT

* Split _GUARD_TYPE_VERSION out of the latter

* Split LOAD_ATTR_CLASS

* Split LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES

* Fix indent of DEOPT_IF in macros

* Split LOAD_ATTR_METHOD_LAZY_DICT

* Split LOAD_ATTR_NONDESCRIPTOR_NO_DICT

* Fix omission of _CHECK_ATTR_METHOD_LAZY_DICT
2023-10-04 16:08:02 +01:00
Guido van Rossum d67edcf0b3
gh-109979: Auto-generate the target for DEOPT_IF() (#110193)
In Python/bytecodes.c, you now write
```
    DEOPT_IF(condition);
```
The code generator expands this to
```
    DEOPT_IF(condition, opcode);
```
where `opcode` is the name of the unspecialized instruction.
This works inside macro expansions too.

**CAVEAT:** The entire `DEOPT_IF(condition)` statement must be on a single line.
If it isn't, the substitution will fail; an error will be printed by the code generator
and the C compiler will report some errors.
2023-10-03 10:13:50 -07:00
Victor Stinner 6387b5313c
gh-108494: Document how to add a project in PCbuild/readme.txt (#110077)
Add _testclinic_limited to Tools/msi/test/test_files.wxs.
2023-10-02 18:53:38 +02:00
dependabot[bot] a431a0f988
build(deps): bump hypothesis from 6.84.0 to 6.87.1 in /Tools (#110174)
Bumps [hypothesis](https://github.com/HypothesisWorks/hypothesis) from 6.84.0 to 6.87.1.
- [Release notes](https://github.com/HypothesisWorks/hypothesis/releases)
- [Commits](https://github.com/HypothesisWorks/hypothesis/compare/hypothesis-python-6.84.0...hypothesis-python-6.87.1)

---
updated-dependencies:
- dependency-name: hypothesis
  dependency-type: direct:production
  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-10-01 17:25:29 +01:00
dependabot[bot] 038c3564fb
PEG generator: bump types-setuptools from 68.1.0.1 to 68.2.0.0 (#110175)
build(deps-dev): bump types-setuptools in /Tools

Bumps [types-setuptools](https://github.com/python/typeshed) from 68.1.0.1 to 68.2.0.0.
- [Commits](https://github.com/python/typeshed/commits)

---
updated-dependencies:
- dependency-name: types-setuptools
  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-10-01 12:38:46 +01:00
Victor Stinner a46e960768
gh-109649: Use os.process_cpu_count() (#110165)
Replace os.cpu_count() with os.process_cpu_count() in modules:

* compileall
* concurrent.futures
* multiprocessing

Replace os.cpu_count() with os.process_cpu_count() in programs:

* _decimal deccheck.py test
* freeze.py
* multissltests.py
* python -m test (regrtest)
* wasm_build.py

Other changes:

* test.pythoninfo logs os.process_cpu_count().
* regrtest gets os.process_cpu_count() / os.cpu_count() in headers.
2023-10-01 03:14:57 +02:00
Victor Stinner 53eb9a676f
gh-110152: regrtest handles cross compilation and HOSTRUNNER (#110156)
* _add_python_opts() now handles cross compilation and HOSTRUNNER.
* display_header() now tells if Python is cross-compiled, display
  HOSTRUNNER, and get the host platform.
* Remove Tools/scripts/run_tests.py script.
* Remove "make hostrunnertest": use "make buildbottest"
  or "make test" instead.
2023-09-30 22:37:23 +00:00
Victor Stinner 74e425ec18
gh-110014: Fix _POSIX_THREADS and _POSIX_SEMAPHORES usage (#110139)
* pycore_pythread.h is now the central place to make sure that
  _POSIX_THREADS and _POSIX_SEMAPHORES macros are defined if
  available.
* Make sure that pycore_pythread.h is included when _POSIX_THREADS
  and _POSIX_SEMAPHORES macros are tested.
* PY_TIMEOUT_MAX is now defined as a constant, since its value
  depends on _POSIX_THREADS, instead of being defined as a macro.
* Prevent integer overflow in the preprocessor when computing
  PY_TIMEOUT_MAX_VALUE on Windows:
  replace "0xFFFFFFFELL * 1000 < LLONG_MAX"
  with "0xFFFFFFFELL < LLONG_MAX / 1000".
* Document the change and give hints how to fix affected code.
* Add an exception for PY_TIMEOUT_MAX  name to smelly.py
* Add PY_TIMEOUT_MAX to the stable ABI
2023-09-30 19:25:54 +02:00
Victor Stinner f3bb00ea12
gh-107954: Refactor initconfig.c: add CONFIG_SPEC (#110146)
Add a specification of the PyConfig structure to factorize the code.
2023-09-30 17:24:06 +00:00
Ned Deily c88037d137
gh-109991: Update GitHub CI workflows to use OpenSSL 3.0.11 and multissltests to use 1.1.1w, 3.0.11, and 3.1.3. (gh-110002) 2023-09-28 00:45:13 -04:00
Guido van Rossum 5bb6f0fcba
gh-104909: Split some more insts into ops (#109943)
These are the most popular specializations of `LOAD_ATTR` and `STORE_ATTR`
that weren't already viable uops:

* Split LOAD_ATTR_METHOD_WITH_VALUES
* Split LOAD_ATTR_METHOD_NO_DICT
* Split LOAD_ATTR_SLOT
* Split STORE_ATTR_SLOT
* Split STORE_ATTR_INSTANCE_VALUE

Also:

* Add `-v` flag to code generator which prints a list of non-viable uops
  (easter-egg: it can print execution counts -- see source)
* Double _Py_UOP_MAX_TRACE_LENGTH to 128



I had dropped one of the DEOPT_IF() calls! :-(
2023-09-27 15:27:44 -07:00
Victor Stinner b89ed9df39
gh-109615: Fix support test_copy_python_src_ignore() (#109958)
Fix the test when run on an installed Python: use "abs_srcdir" of
sysconfig, and skip the test if the Python source code cannot be
found.

* Tools/patchcheck/patchcheck.py, Tools/freeze/test/freeze.py and
  Lib/test/libregrtest/utils.py now first try to get "abs_srcdir"
  from sysconfig, before getting "srcdir" from sysconfig.
* test.pythoninfo logs sysconfig "abs_srcdir".
2023-09-27 12:32:12 +02:00
Victor Stinner 1512d6c6ee
gh-109615: Fix test_tools.test_freeze SRCDIR (#109935)
Fix copy_source_tree() function of test_tools.test_freeze:

* Don't copy SRC_DIR/build/ anymore. This directory is modified by
  other tests running in parallel.
* Add test.support.copy_python_src_ignore().
* Use sysconfig to get the source directory.
* Use sysconfig.get_config_var() to get CONFIG_ARGS variable.
2023-09-27 08:18:39 +00:00
Ammar Askar a829356f86
gh-109098: Fuzz re module instead of internal sre (#109911)
* gh-109098: Fuzz re module instead of internal sre
* Fix c-analyzer globals test failure
* Put globals exception in ignored.tsv
2023-09-26 15:35:49 -07:00
OmniTroid 4390c13148
Fix argument ordering of embuilder command documented in `Tools/wasm/README.md` (GH-109863) 2023-09-26 13:22:00 -07:00
Victor Stinner fbfec5642e
gh-109566: regrtest reexecutes the process (#109909)
When --fast-ci or --slow-ci option is used, regrtest now replaces the
current process with a new process to add "-u -W default -bb -E"
options to Python.

Changes:

* PCbuild/rt.bat and Tools/scripts/run_tests.py no longer need to add
  "-u -W default -bb -E" options to Python: it's now done by
  regrtest.
* Fix Tools/scripts/run_tests.py: flush stdout before replacing the
  process. Previously, buffered messages were lost.
2023-09-26 20:46:52 +02:00
Victor Stinner 859618c8cd
gh-109566, regrtest: Add --fast-ci and --slow-ci options (#109570)
* Add --fast-ci and --slow-ci options to libregrtest:

  * --fast-ci uses a default timeout of 10 minutes and "-u all,-cpu"
    (skip slowest tests).
  * --slow-ci uses a default timeout of 20 minues and "-u all" (run
    all tests).

* regrtest header now lists test resources.
* Makefile changes:

  * "make test", "make hostrunnertest" and "make coverage-report" now
    use --fast-ci option and TESTTIMEOUT variable.
  * "make buildbottest" now uses "--slow-ci". Remove options which
    became redundant with "--slow-ci".
  * "make testall" and "make testuniversal" now use --slow-ci option
    and TESTTIMEOUT variable.
  * "make testall" now uses "find -exec rm ..." instead of
    "find ... -print|xargs rm ...", same as "make clean".

* GitHub Actions workflow:

  * Ubuntu and Address Sanitizer jobs now use "make test". Remove
    options which became redundant with "--fast-ci".
  * Windows jobs now use --fast-ci option.
  * Use -j0 to detect the number of CPUs.

* Set Makefile TESTTIMEOUT default to an empty string, since
  --slow-ci and --fast-ci use different default timeout. It's now
  accepted to pass "--timeout=" to regrtest: treated as not timeout.
* Tools/scripts/run_tests.py now uses --fast-ci option.
* Tools/buildbot/test.bat now uses --slow-ci option. Remove
  --timeout=1200 option, redundant with --slow-ci.
2023-09-26 17:22:50 +02:00
Hugo van Kemenade f19416534a
Code: Update Donghee Na's name (#109744) 2023-09-25 18:17:34 +03:00
Pablo Galindo Salgado b28ffaa193
gh-109596: Ensure repeated rules in the grammar are not allowed and fix incorrect soft keywords (#109606) 2023-09-22 19:03:23 +01:00
Victor Stinner 09a25616a9
gh-109723: Disable Py_BUILD_CORE in _testcapi (#109727)
Make sure that the internal C API is not tested by mistake by
_testcapi.

Undefine Py_BUILD_CORE_BUILTIN and Py_BUILD_CORE_MODULE macros in
Modules/_testcapi/parts.h: move code from _testcapimodule.c.

heaptype_relative.c and vectorcall_limited.c are using the limited C
API which is incompatible with the internal C API.

Move test_long_numbits() from _testcapi to _testinternalcapi since it
uses the internal C API "pycore_long.h".

Fix Modules/_testcapi/pyatomic.c: don't include Python.h directly,
just include _testcapi/parts.h.

Ajust "make check-c-globals" for these changes.
2023-09-22 14:54:37 +00:00
Victor Stinner 3f5c5649cf
gh-104469: Disallow using Py_LIMITED_API with Py_BUILD_CORE (#109690)
Fix make check-c-globals: complete USE_LIMITED_C_API list of the
c-analyzer.
2023-09-22 01:21:07 +02:00
Heinz-Alexander Fuetterer ef6d475db3
Fix typos in docs and comments (#109619) 2023-09-20 16:58:23 +00:00
James Gerity def828995a
fixes gh-109559: Update `unicodedata` for Unicode 15.1.0 (GH-109560)
---------

Co-authored-by: Benjamin Peterson <benjamin@python.org>
2023-09-19 22:07:47 -07:00
Sam Gross 0c89056fe5
gh-108724: Add PyMutex and _PyParkingLot APIs (gh-109344)
PyMutex is a one byte lock with fast, inlineable lock and unlock functions for the common uncontended case.  The design is based on WebKit's WTF::Lock.

PyMutex is built using the _PyParkingLot APIs, which provides a cross-platform futex-like API (based on WebKit's WTF::ParkingLot).  This internal API will be used for building other synchronization primitives used to implement PEP 703, such as one-time initialization and events.

This also includes tests and a mini benchmark in Tools/lockbench/lockbench.py to compare with the existing PyThread_type_lock.

Uncontended acquisition + release:
* Linux (x86-64): PyMutex: 11 ns, PyThread_type_lock: 44 ns
* macOS (arm64): PyMutex: 13 ns, PyThread_type_lock: 18 ns
* Windows (x86-64): PyMutex: 13 ns, PyThread_type_lock: 38 ns

PR Overview:

The primary purpose of this PR is to implement PyMutex, but there are a number of support pieces (described below).

* PyMutex:  A 1-byte lock that doesn't require memory allocation to initialize and is generally faster than the existing PyThread_type_lock.  The API is internal only for now.
* _PyParking_Lot:  A futex-like API based on the API of the same name in WebKit.  Used to implement PyMutex.
* _PyRawMutex:  A word sized lock used to implement _PyParking_Lot.
* PyEvent:  A one time event.  This was used a bunch in the "nogil" fork and is useful for testing the PyMutex implementation, so I've included it as part of the PR.
* pycore_llist.h:  Defines common operations on doubly-linked list.  Not strictly necessary (could do the list operations manually), but they come up frequently in the "nogil" fork. ( Similar to https://man.freebsd.org/cgi/man.cgi?queue)

---------

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2023-09-19 09:54:29 -06:00
Victor Stinner 67d9363372
gh-109566: Run GHA and buildbot tests with --fail-rerun (#109567) 2023-09-19 15:50:27 +02:00
Nikita Sobolev f65497fd25
gh-109125: Run mypy on `Tools/wasm` (#109126) 2023-09-18 23:49:26 -06:00
DongWoo Son df8b3a46a7
Fix a typo in c-analyzer (#109213)
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
Co-authored-by: Dale Collison <92315623+dcollison@users.noreply.github.com>
2023-09-18 00:27:54 -07:00
Michael Droettboom 19f5effc27
GH-109373: Store metadata required for pystats comparison in the JSON (GH-109374) 2023-09-15 13:10:46 -07:00
Guido van Rossum a7a079798d
gh-109287: Desugar inst(X) to op(X); macro(X) = X (#109294)
This makes the internal representation in the code generator simpler: there's a list of ops, and a list of macros, and there's no special-casing needed for ops that aren't macros. (There's now special-casing for ops that are also macros, but that's simpler.)
2023-09-15 08:39:05 -07:00
Serhiy Storchaka 1f885df2a5
gh-107782: Use _testcapi to test non-representable signatures (GH-109325)
Builtin functions and methods that have non-representable signatures today
will have representable signatures yesterday, and they will become unusable
for testing this feature.

So we need to add special functions and methods to the _testcapi module
that always have non-representable signatures.
2023-09-14 09:12:17 +03:00
Sam Gross baaac99487
Fix invocation of wasm_build.py for node (GH-109383) 2023-09-13 15:28:08 -07:00
Michael Droettboom 5dcbbd8861
GH-109330: Dump and compare stats using opcode names, not numbers (GH-109335) 2023-09-12 14:12:57 -07:00
Guido van Rossum b86ce91bfe
gh-106581: Honor 'always_exits' in write_components() (#109338)
I must have overlooked this when refactoring the code generator.
The Tier 1 interpreter contained a few silly things like
```
            goto resume_frame;
            STACK_SHRINK(1);
```
(and other variations, some where the unconditional `goto` was hidden in a macro).
2023-09-12 17:58:40 +00:00
Irit Katriel 8b55adfa8f
gh-109256: allocate opcode IDs for internal opcodes in their own range (#109269) 2023-09-12 10:36:17 +00:00
Guido van Rossum fbaf77eb9b
gh-109214: Rename SAVE_IP to _SET_IP, and similar (#109285)
* Rename SAVE_IP to _SET_IP
* Rename EXIT_TRACE to _EXIT_TRACE
* Rename SAVE_CURRENT_IP to _SAVE_CURRENT_IP
* Rename INSERT to _INSERT (This is for Ken Jin's abstract interpreter)
* Rename IS_NONE to _IS_NONE
* Rename JUMP_TO_TOP to _JUMP_TO_TOP
2023-09-11 15:39:19 -07:00
Guido van Rossum bcce5e2718
gh-109039: Branch prediction for Tier 2 interpreter (#109038)
This adds a 16-bit inline cache entry to the conditional branch instructions POP_JUMP_IF_{FALSE,TRUE,NONE,NOT_NONE} and their instrumented variants, which is used to keep track of the branch direction.

Each time we encounter these instructions we shift the cache entry left by one and set the bottom bit to whether we jumped.

Then when it's time to translate such a branch to Tier 2 uops, we use the bit count from the cache entry to decided whether to continue translating the "didn't jump" branch or the "jumped" branch.

The counter is initialized to a pattern of alternating ones and zeros to avoid bias.

The .pyc file magic number is updated. There's a new test, some fixes for existing tests, and a few miscellaneous cleanups.
2023-09-11 18:20:24 +00:00
Alex Waygood 697c9dcf8f
gh-108455: peg_generator: enable mypy's `--warn-unreachable` setting and `redundant-expr` error code (#109160) 2023-09-08 22:05:40 +01:00
Michael Droettboom 52beebc856
gh-109136: Fix summarize_stats.py tool (#109137) 2023-09-08 18:23:58 +02:00
Mark Shannon 15d4c9fabc
GH-108716: Turn off deep-freezing of code objects. (GH-108722) 2023-09-08 10:34:40 +01:00
Mark Shannon 0858328ca2
GH-108614: Add `RESUME_CHECK` instruction (GH-108630) 2023-09-07 14:39:03 +01:00
Victor Stinner db1ee6a19a
gh-108740: Fix "make regen-all" race condition (#108741)
Fix a race condition in "make regen-all". The deepfreeze.c source and
files generated by Argument Clinic are now generated or updated
before generating "global objects". Previously, some identifiers may
miss depending on the order in which these files were generated.

* "make regen-global-objects": Make sure that deepfreeze.c is
  generated and up to date, and always run "make clinic".
* "make clinic" no longer runs generate_global_objects.py script.
* "make regen-deepfreeze" now only updates deepfreeze.c (C file).
  It doesn't build deepfreeze.o (object) anymore.
* Remove misleading messages in "make regen-global-objects" and
  "make clinic". They are now outdated, these commands are now
  safe to use.
* Document generates files in Doc/using/configure.rst.

Co-authored-by: Erlend E. Aasland <erlend@python.org>
2023-09-06 20:09:21 +02:00
Łukasz Langa f8a047941f
gh-109002: Ensure only one wheel for each vendored package (#109003)
Output with one wheel:
```
❯ GITHUB_ACTIONS=true ./Tools/build/verify_ensurepip_wheels.py
Verifying checksum for /Volumes/RAMDisk/cpython/Lib/ensurepip/_bundled/pip-23.2.1-py3-none-any.whl.
Expected digest: 7ccf472345f20d35bdc9d1841ff5f313260c2c33fe417f48c30ac46cccabf5be
Actual digest:   7ccf472345f20d35bdc9d1841ff5f313260c2c33fe417f48c30ac46cccabf5be
::notice file=/Volumes/RAMDisk/cpython/Lib/ensurepip/_bundled/pip-23.2.1-py3-none-any.whl::Successfully verified the checksum of the pip wheel.
```

Output with two wheels:
```
❯ GITHUB_ACTIONS=true ./Tools/build/verify_ensurepip_wheels.py
::error file=/Volumes/RAMDisk/cpython/Lib/ensurepip/_bundled/pip-22.0.4-py3-none-any.whl::Found more than one wheel for package pip.

::error file=/Volumes/RAMDisk/cpython/Lib/ensurepip/_bundled/pip-23.2.1-py3-none-any.whl::Found more than one wheel for package pip.
```

Output without wheels:
```
❯ GITHUB_ACTIONS=true ./Tools/build/verify_ensurepip_wheels.py
::error file=::Could not find a pip wheel on disk.
```
2023-09-06 16:49:44 +02:00
KH 44892b1c52
Fix a typo in umarshal.py (#108803)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2023-09-06 09:06:41 +00:00
Guido van Rossum b87263be9b
gh-106581: Support multiple uops pushing new values (#108895)
Also avoid the need for the awkward .clone() call in the argument
to mgr.adjust_inverse() and mgr.adjust().
2023-09-05 13:58:39 -07:00
Nikita Sobolev 6ead5bd6ae
Disable `differing_test_runners` health check (#108886) 2023-09-04 18:31:58 +00:00
Serhiy Storchaka 1796c191b4
gh-108494: Argument Clinic: inline parsing code for positional-only parameters in the limited C API (GH-108622) 2023-09-03 17:28:14 +03:00
Victor Stinner ad73674283
gh-107603: Argument Clinic: Only include pycore_gc.h if needed (#108726)
Argument Clinic now only includes pycore_gc.h if PyGC_Head is needed,
and only includes pycore_runtime.h if _Py_ID() is needed.

* Add 'condition' optional argument to Clinic.add_include().
* deprecate_keyword_use() includes pycore_runtime.h when using
  the _PyID() function.
* Fix rendering of includes: comments start at the column 35.
* Mark PC/clinic/_wmimodule.cpp.h and
  "Objects/stringlib/clinic/*.h.h" header files as generated in
  .gitattributes.

Effects:

* 42 header files generated by AC no longer include the internal C
  API, instead of 4 header files before. For example,
  Modules/clinic/_abc.c.h no longer includes the internal C API.
* Fix _testclinic_depr.c.h: it now always includes pycore_runtime.h
  to get _Py_ID().
2023-08-31 23:42:34 +02:00
Mark Shannon 059bd4d299
GH-108614: Remove non-debug uses of `#if TIER_ONE` and `#if TIER_TWO` from `_POP_FRAME` op. (GH-108685) 2023-08-31 11:34:52 +01:00
Alex Waygood b89b838ebc
gh-108455: peg_generator: use `types-setuptools==68.1.0.1` in CI (#108697) 2023-08-31 08:41:25 +01:00
Alex Waygood 77e8f233ac
gh-108455: peg_generator: install two stubs packages before running mypy (#108637) 2023-08-29 20:14:08 +01:00
Guido van Rossum 4f22152713
gh-107557: Remove unnecessary SAVE_IP instructions (#108583)
Also remove NOP instructions.

The "stubs" are not optimized in this fashion (their SAVE_IP should always be preserved since it's where to jump next, and they don't contain NOPs by their nature).
2023-08-29 16:51:51 +00:00
Nikita Sobolev f8be2e262c
gh-108455: peg generator: Use `strict_optional=True` for `grammar_parser` (#108629) 2023-08-29 13:02:52 +01:00
Victor Stinner e675e515ae
gh-108494: Argument Clinic: fix option group for Limited C API (#108574)
Use PyTuple_Size() instead of PyTuple_GET_SIZE().
2023-08-29 13:33:28 +02:00
Alex Waygood 0d140b8c5e
gh-108455: peg_generator: make the mypy config slightly stricter (#108627)
* Enable `--no-implicit-reexport`

* Enable the `truthy-bool` error code

* Enable the `ignore-without-code` error code

* Explicitly note that `--warn-unreachable` cannot yet be enabled
2023-08-29 11:23:22 +00:00
Alex Waygood c879b9fddf
gh-108455: Simplify the peg_generator mypy config (#108620)
make it easier to see exactly which options from mypy's `--strict` mode can't currently be enabled
2023-08-29 10:24:06 +00:00
Victor Stinner 301eb7e607
gh-106320: Remove _PyAnextAwaitable_Type from the public C API (#108597)
It's not needed to declare it in Include/iterobject.h: just use
"extern" where it's used (only in object.c).
2023-08-29 02:05:11 +00:00
Adam Turner 0bd2ba553d
GH-107603: Clinic: Pass specific attributes to ``print_block()`` (#108581) 2023-08-28 21:31:45 +00:00
Nikita Sobolev cf7ba83eb2
gh-108455: Run `mypy` on `Tools/peg_generator` (#108456)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-08-28 21:04:12 +01:00
Alex Waygood 242bef459b
gh-108494: Argument clinic: Improve the `parse_file()` API (#108575)
Co-authored-by: Victor Stinner <vstinner@python.org>
2023-08-28 18:25:16 +00:00
Serhiy Storchaka bc5356bb5d
gh-108494: Argument Clinic: fix support of Limited C API (GH-108536) 2023-08-28 16:04:27 +03:00
Erlend E. Aasland d90973340b
gh-104683: Argument Clinic: Refactor the module and class resolver (#108552) 2023-08-28 14:41:05 +02:00
Victor Stinner 8ba4714611
gh-106320: Remove private AC converter functions (#108505)
Move these private functions to the internal C API
(pycore_abstract.h):

* _Py_convert_optional_to_ssize_t()
* _PyNumber_Index()

Argument Clinic now emits #include "pycore_abstract.h" when these
functions are used.

The parser of the c-analyzer tool now uses a list of files which use
the limited C API, rather than a list of files using the internal C
API.
2023-08-26 04:05:17 +02:00
Victor Stinner 6353c21b78
gh-106320: Remove private _PyLong_FileDescriptor_Converter() (#108503)
Move the private _PyLong converter functions to the internal C API

* _PyLong_FileDescriptor_Converter(): moved to pycore_fileutils.h
* _PyLong_Size_t_Converter(): moved to pycore_long.h

Argument Clinic now emits includes for pycore_fileutils.h and
pycore_long.h when these functions are used.
2023-08-26 03:18:09 +02:00
Victor Stinner 713afb8804
gh-106320: Remove private _PyLong converter functions (#108499)
Move these private functions to the internal C API (pycore_long.h):

* _PyLong_UnsignedInt_Converter()
* _PyLong_UnsignedLongLong_Converter()
* _PyLong_UnsignedLong_Converter()
* _PyLong_UnsignedShort_Converter()

Argument Clinic now emits #include "pycore_long.h" when these
functions are used.
2023-08-26 02:24:27 +02:00
Victor Stinner 86bc9e35c4
gh-108494: AC supports pos-only args in limited C API (#108498)
AC now checks for "#define Py_LIMITED_API" pattern to use the limited
C API.
2023-08-26 00:39:24 +02:00
Victor Stinner 73d33c1a30
gh-107603: Argument Clinic can emit includes (#108486)
* Add Clinic.add_include() method
* Add CConverter.include and CConverter.add_include()
* Printer.print_block() gets a second parameter: clinic.
* Remove duplicated declaration of "clinic" global variable.
2023-08-26 00:01:10 +02:00
Victor Stinner 1dd9510977
gh-108494: Argument Clinic partial supports of Limited C API (#108495)
Argument Clinic now has a partial support of the
Limited API:

* Add --limited option to clinic.c.
* Add '_testclinic_limited' extension which is built with
  the limited C API version 3.13.
* For now, hardcode in clinic.py that "_testclinic_limited.c" targets
  the limited C API.
2023-08-25 23:22:08 +02:00
Irit Katriel 5f41376e93
gh-107901: add the HAS_EVAL_BREAK instruction flag (#108375) 2023-08-25 18:33:59 +00:00
Alex Waygood 5a25daa512
gh-104504: Cases generator: enable mypy's `possibly-undefined` error code (#108454) 2023-08-25 18:08:29 +01:00
Guido van Rossum ddf66b54ed
gh-106581: Split CALL_BOUND_METHOD_EXACT_ARGS into uops (#108462)
Instead of using `GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS)` we just add the macro elements of the latter to the macro for the former. This requires lengthening the uops array in struct opcode_macro_expansion. (It also required changes to stacking.py that were merged already.)
2023-08-24 17:36:00 -07:00
Victor Stinner 4e5a7284ee
gh-108444: Argument Clinic uses PyLong_AsInt() (#108458)
Argument Clinic now uses the new public PyLong_AsInt(), rather than
the old name _PyLong_AsInt().
2023-08-25 00:51:22 +02:00
Guido van Rossum 88941d665f
gh-106581: Fix two bugs in the code generator's copy optimization (#108380)
I was comparing the last preceding poke with the *last* peek,
rather than the *first* peek.

Unfortunately this bug obscured another bug:
When the last preceding poke is UNUSED, the first peek disappears,
leaving the variable unassigned. This is how I fixed it:

- Rename CopyEffect to CopyItem.
- Change CopyItem to contain StackItems instead of StackEffects.
- Update those StackItems when adjusting the manager higher or lower.
- Assert that those StackItems' offsets are equivalent.
- Other clever things.

---------

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2023-08-24 19:10:51 +00:00
Victor Stinner f1ae706ca5
gh-107211: No longer export internal functions (7) (#108425)
No longer export _PyUnicode_FromId() internal C API function.

Change comment style to "// comment" and add comment explaining why
other functions have to be exported.

Update Tools/build/generate_token.py to update Include/internal/pycore_token.h
comments.
2023-08-24 17:40:56 +02:00
Irit Katriel 72119d16a5
gh-105481: remove regen-opcode. Generated _PyOpcode_Caches in regen-cases. (#108367) 2023-08-23 18:39:00 +01:00
Alex Waygood a0bb4a39d1
Fix spurious diff if the cases generator is run on Windows (#108319) 2023-08-22 20:49:39 +01:00
Dennis Sweeney 86617518c4
gh-108179: Add error message for parser stack overflows (#108256) 2023-08-22 08:41:50 +01:00
Victor Stinner 0dd3fc2a64
gh-108216: Cleanup #include in internal header files (#108228)
* Add missing includes.
* Remove unused includes.
* Update old include/symbol names to newer names.
* Mention at least one included symbol.
* Sort includes.
* Update Tools/cases_generator/generate_cases.py used to generated
  pycore_opcode_metadata.h.
* Update Parser/asdl_c.py used to generate pycore_ast.h.
* Cleanup also includes in _testcapimodule.c and _testinternalcapi.c.
2023-08-21 18:05:59 +00:00
Victor Stinner 21c0844742
gh-108220: Internal header files require Py_BUILD_CORE to be defined (#108221)
* pycore_intrinsics.h does nothing if included twice
  (add #ifndef and #define).
* Update Tools/cases_generator/generate_cases.py to generate the
  Py_BUILD_CORE test.
* _bz2, _lzma, _opcode and zlib extensions now define the
  Py_BUILD_CORE_MODULE macro to use internal headers
  (pycore_code.h, pycore_intrinsics.h and pycore_blocks_output_buffer.h).
2023-08-21 19:15:52 +02:00
Serhiy Storchaka 60942cccb1
gh-95065, gh-107704: Argument Clinic: support multiple '/ [from ...]' and '* [from ...]' markers (GH-108132) 2023-08-21 13:59:58 +00:00
Alex Waygood 05ef4ca94c
gh-104504: cases generator: Add `--warn-unreachable` to the mypy config (#108112) 2023-08-21 00:40:41 +01:00
Serhiy Storchaka 2f311437cd
gh-107704: Argument Clinic: add support for deprecating keyword use of parameters (GH-107984)
It is now possible to deprecate passing keyword arguments for
keyword-or-positional parameters with Argument Clinic, using the new
'/ [from X.Y]' syntax.
(To be read as "positional-only from Python version X.Y")

Co-authored-by: Erlend E. Aasland <erlend@python.org>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-19 10:13:35 +03:00
Ned Deily ed25f09716
gh-107565: Update multissltests and GitHub CI workflows to use OpenSSL 1.1.1v, 3.0.10, and 3.1.2. (GH-107896) 2023-08-18 15:48:20 -04:00
Dong-hee Na 28cab71f95
gh-104504: Run mypy on cases_generator in CI (and blacken the code) (gh-108090)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-18 22:42:45 +09:00
Guido van Rossum 61c7249759
gh-106581: Project through calls (#108067)
This finishes the work begun in gh-107760. When, while projecting a superblock, we encounter a call to a short, simple function, the superblock will now enter the function using `_PUSH_FRAME`, continue through it, and leave it using `_POP_FRAME`, and then continue through the original code. Multiple frame pushes and pops are even possible. It is also possible to stop appending to the superblock in the middle of a called function, when running out of space or encountering an unsupported bytecode.
2023-08-17 11:29:58 -07:00
Erlend E. Aasland 292a22bdc2
gh-104683: Argument Clinic: Remove unreachable code from _module_and_class() (#108092)
'not hasattr(parent, "classes")' is always false, since 'parent' is an
instance of either the Module, Class, or Clinic classes, and all of
them has a "classes" attribute.
2023-08-17 18:16:08 +00:00
Irit Katriel 0b243c2f66
gh-105481: opcode.h is no longer generated during the build (#108080) 2023-08-17 17:07:58 +01:00
Irit Katriel 2da67a5789
gh-105481: fix out of date comment (#108079) 2023-08-17 10:25:28 +00:00
Guido van Rossum dc8fdf5fd5
gh-106581: Split `CALL_PY_EXACT_ARGS` into uops (#107760)
* Split `CALL_PY_EXACT_ARGS` into uops

This is only the first step for doing `CALL` in Tier 2.
The next step involves tracing into the called code object and back.
After that we'll have to do the remaining `CALL` specialization.
Finally we'll have to deal with `KW_NAMES`.

Note: this moves setting `frame->return_offset` directly in front of
`DISPATCH_INLINED()`, to make it easier to move it into `_PUSH_FRAME`.
2023-08-16 16:26:43 -07:00
Irit Katriel 665a4391e1
gh-105481: generate op IDs from bytecode.c instead of hard coding them in opcode.py (#107971) 2023-08-16 22:25:18 +00:00
Erlend E. Aasland 42429d3b9a
gh-104683: Argument Clinic: Extract parse function name helper (#107964)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-16 13:47:15 +00:00
Ken Jin e28b0dc86d
gh-107557: Setup abstract interpretation (#107847)
Co-authored-by: Guido van Rossum <gvanrossum@users.noreply.github.com>
Co-authored-by: Jules <57632293+juliapoo@users.noreply.github.com>
2023-08-15 18:04:17 +00:00
Erlend E. Aasland 607f18c894
gh-107972: Argument Clinic: Ensure a C basename is provided after 'as' (#107973)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2023-08-15 14:41:40 +00:00
Erlend E. Aasland e90036c9bd
gh-107880: Argument Clinic: Fix regression in gh-107885 (#107974)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-15 14:00:52 +00:00
Guido van Rossum a2a4b9f1ec
Attempt to speed up deepfreeze.py (#107887)
* Instead of calling get_identifiers_and_strings(), extract identifiers and strings from pycore_global_strings.h.
* Avoid ast.literal_eval(), it's very slow.
2023-08-14 14:41:27 -07:00
Irit Katriel 39745347f6
gh-105481: reduce repetition in opcode metadata generation code (#107942) 2023-08-14 18:36:29 +00:00
Erlend E. Aasland 9b75ada6e4
gh-107880: Teach Argument Clinic to clone __init__ and __new__ methods (#107885) 2023-08-13 12:13:11 +02:00
Erlend E. Aasland ee40b3e20d
gh-107883: Argument Clinic: Handle full module/class path in Function.fulldisplayname (#107884)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-12 23:46:00 +00:00
Dong-hee Na bf707749e8
gh-106797: Remove warning logs from Python/generated_cases.c.h and executor_cases.c.h (gh-107889)
gh-106797: Remove warning logs from Python/generated_cases.c.h
2023-08-13 04:36:46 +09:00
Irit Katriel caa41a4f1d
gh-105481: split opcode_ids.h out of opcode.h so that it can be generated separately (#107866) 2023-08-11 17:42:01 +01:00
Serhiy Storchaka 3901c991e1
gh-84805: Autogenerate signature for METH_NOARGS and METH_O extension functions (GH-107794) 2023-08-11 18:08:38 +03:00
Martin DeMello 50bbc56009
Fix the long64 reader in umarshal.py (GH-107828) 2023-08-10 23:43:14 +03:00
Erlend E. Aasland 39ef93edb9
gh-95065: Argument Clinic: Add functional tests of deprecated positionals (#107768)
Move the "deprecated positinal" tests from clinic.test.c to
_testclinic.c. Mock PY_VERSION_HEX in order to prevent generated
compiler warnings/errors to trigger. Put clinic code for deprecated
positionals in Modules/clinic/_testclinic_depr_star.c.h for easy
inspection of the generated code.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-08-10 07:19:05 +00:00
Guido van Rossum 4890bfe1f9
Update README for the cases generator (#107826) 2023-08-10 01:05:51 +00:00
Carl Meyer 2ec16fed14
gh-91054: make code watcher tests resilient to other watchers (#107821) 2023-08-09 16:42:32 -06:00
Erlend E. Aasland 0a7f48b9a8
gh-95065: Produce nicer deprecation messages in Argument Clinic (#107808) 2023-08-09 13:28:18 +00:00
Erlend E. Aasland 1b3f5f24af
gh-104683: Argument Clinic: Params now render their own docstrings (#107790)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-09 12:44:26 +00:00
Alex Waygood 65ce3652fa
gh-104683: Remove unused variables from `Tools/clinic` and tests for `Tools/clinic` (#107771) 2023-08-09 11:24:05 +01:00
Erlend E. Aasland 925bbc2166
gh-80282: Argument Clinic: Add clarifying comment about ASCII docstring limitation (#107764)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-09 07:55:34 +02:00
Erlend E. Aasland 73507382ac
gh-104683: Argument Clinic: refactor format_docstring() (#107623)
Extract helper methods for formatting the signature and parameter
sections, and clean up the remaining function body.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2023-08-08 21:12:35 +00:00
Erlend E. Aasland 0be3743f54
gh-104683: Add --exclude option to Argument Clinic CLI (#107770)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-08-08 20:50:54 +00:00
Alex Waygood 7c5153de5a
gh-106368: Argument clinic: add tests for more failure paths (#107731) 2023-08-08 12:12:49 +00:00
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
Guido van Rossum 2df58dcd50
gh-106812: Small stack effect fixes (#107759)
- Generalize the syntax for the type of a stack effect to allow a trailing `*`,
  so we can declare something as e.g. `PyCodeObject *`.

- When generating assignments for stack effects,
  the type of the value on the stack should be the default (i.e., `PyObject *`)
  even when the variable copied to/from it has a different type,
  so that an appropriate cast is generated
  However, not when the variable is an array --
  then the type is taken from the variable (as it is always `PyObject **`).
2023-08-07 21:32:42 -07: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
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
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
Guido van Rossum 032f480909
Thoroughly refactor the cases generator (#107151)
This mostly extracts a whole bunch of stuff out of generate_cases.py into separate files, but there are a few other things going on here.

- analysis.py: `Analyzer` etc.
- instructions.py: `Instruction` etc.
- flags.py: `InstructionFlags`, `variable_used`, `variable_used_unspecialized`
- formatting.py: `Formatter` etc.
- Rename parser.py to parsing.py, to avoid conflict with stdlib parser.py
- Blackify most things
- Fix most mypy errors
- Remove output filenames from Generator state, add them to `write_instructions()` etc.
- Fix unit tests
2023-07-24 09:38:23 -07: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
Victor Stinner 22422e9d1a
gh-106320: Remove private _PyInterpreterID C API (#107053)
Move the private _PyInterpreterID C API to the internal C API: add a
new pycore_interp_id.h header file.

Remove Include/interpreteridobject.h and
Include/cpython/interpreteridobject.h header files.
2023-07-22 19:31:55 +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
Guido van Rossum 1218910860
gh-105540: Show source files relative to root (#106927)
This restores a corner case: when the generator is run with working directory set to Tools/cases_generator, the source filenames listed in the generated provenance header should be relative to the repo root directory.
2023-07-20 23:08:52 +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
Brandt Bucher 8f4de57699
GH-106701: Move _PyUopExecute to Python/executor.c (GH-106924) 2023-07-20 20:37:19 +00:00
Irit Katriel 9c81fc2dbe
gh-105481: do not auto-generate pycore_intrinsics.h (#106913) 2023-07-20 17:46:04 +01:00
Brandt Bucher 214a25dd81
GH-104584: Miscellaneous fixes for -Xuops (GH-106908) 2023-07-20 16:35:39 +00:00
Charlie Zhao a1620dd7b7
gh-106078: Prepare to isolate decimal module (#106880)
* move signal_map to global_state

* move cond_map to global_state
2023-07-20 09:24:35 +00:00
Irit Katriel 40f3f11a77
gh-105481: Generate the opcode lists in dis from data extracted from bytecodes.c (#106758) 2023-07-18 19:42:44 +01:00
Guido van Rossum 1e36ca63f9
Small fixes to code generator (#106845)
These repair nits I found in PR gh-106798 (issue gh-106797) and in PR gh-106716 (issue gh-106706).
2023-07-18 01:30:41 +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
Guido van Rossum 8e9a1a0322
gh-106603: Make uop struct a triple (opcode, oparg, operand) (#106794) 2023-07-17 12:12:33 -07:00
Guido van Rossum 2b94a05a0e
gh-106581: Add 10 new opcodes by allowing `assert(kwnames == NULL)` (#106707)
By turning `assert(kwnames == NULL)` into a macro that is not in the "forbidden" list, many instructions that formerly were skipped because they contained such an assert (but no other mention of `kwnames`) are now supported in Tier 2. This covers 10 instructions in total (all specializations of `CALL` that invoke some C code):
- `CALL_NO_KW_TYPE_1`
- `CALL_NO_KW_STR_1`
- `CALL_NO_KW_TUPLE_1`
- `CALL_NO_KW_BUILTIN_O`
- `CALL_NO_KW_BUILTIN_FAST`
- `CALL_NO_KW_LEN`
- `CALL_NO_KW_ISINSTANCE`
- `CALL_NO_KW_METHOD_DESCRIPTOR_O`
- `CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS`
- `CALL_NO_KW_METHOD_DESCRIPTOR_FAST`
2023-07-17 11:02:58 -07: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
Dong-hee Na 48956cc60e
gh-106797: Remove warning logs from Python/generated_cases.c.h (gh-106798) 2023-07-17 09:09:11 +09: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
Nikita Sobolev c41320701b
gh-105540: Convert `pytest` tests of `cases_generator` to regular tests (#106713) 2023-07-16 16:05:24 -07:00
Kevin Diem cc25ca16ee
gh-106706: Streamline family syntax in cases generator DSL (#106716)
From `family(opname, STRUCTSIZE) = OPNAME + SPEC1 + ... +  SPECn;`
to `family(OPNAME, STRUCTSIZE) = SPEC1 + ... + SPECn;`
2023-07-16 08:16:34 -07:00
Erlend E. Aasland bbf6297985
gh-104050: Argument Clinic: Annotate BlockParser (#106750) 2023-07-15 10:11:32 +00:00
Irit Katriel 6a70edf24c
gh-105481: expose opcode metadata via the _opcode module (#106688) 2023-07-14 18:41:52 +01: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
Guido van Rossum e6e0ea0113
gh-106701: Move the hand-written Tier 2 uops to bytecodes.c (#106702)
This moves EXIT_TRACE, SAVE_IP, JUMP_TO_TOP, and
_POP_JUMP_IF_{FALSE,TRUE} from ceval.c to bytecodes.c.

They are no less special than before, but this way
they are discoverable o the copy-and-patch tooling.
2023-07-13 12:14:51 -07:00
Mark Shannon 487861c6ae
GH-104909: Split `LOAD_ATTR_INSTANCE_VALUE` into micro-ops (GH-106678) 2023-07-13 16:36:19 +01: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
Irit Katriel 2ca008e2b7
gh-105481: move Python/opcode_metadata.h to Include/internal/pycore_opcode_metadata.h (#106673) 2023-07-12 11:30:25 +01:00
Alex Waygood 7ce3ea4906
gh-104683: Argument clinic: Minor readability improvements for `Destination.__init__` (#106652) 2023-07-11 23:08:28 +00:00
Ijtaba Hussain de827322ca
gh-103186: In test_tools.freeze, fetch CONFIG_ARGS from original source directory (#103213)
Fetch CONFIG_ARGS from the original source directory, instead of from
the copied source tree. When "make clean" is executed in the copied
source tree, the build directory is cleared and the configure argument
lookup fails. However, the original source directory still contains this
information.
2023-07-11 22:22:18 +00:00
Alex Waygood d0972c77aa
gh-104050: Argument Clinic: Annotate the `Block` class (#106519) 2023-07-11 21:21:14 +00:00
Guido van Rossum cabd6e8a10
gh-106529: Support JUMP_BACKWARD in Tier 2 (uops) (#106543)
During superblock generation, a JUMP_BACKWARD instruction is translated to either a JUMP_TO_TOP micro-op (when the target of the jump is exactly the beginning of the superblock, closing the loop), or a SAVE_IP + EXIT_TRACE pair, when the jump goes elsewhere.

The new JUMP_TO_TOP instruction includes a CHECK_EVAL_BREAKER() call, so a closed loop can still be interrupted.
2023-07-11 18:08:10 +00:00
Eisuke Kawashima 64c0890b69
wasm: do not use inline comment in .editorconfig (#106610)
It is no longer valid since 0.15.0
https://github.com/editorconfig/specification/blob/v0.15/index.rst#no-inline-comments
2023-07-11 23:55:37 +09:00
Irit Katriel 388b5daa52
gh-106360: remove redundant #ifdef (#106622) 2023-07-11 13:41:50 +01:00
Charlie Zhao e5c32a811c
gh-106078: Move external C-API functions to decimal module global state (#106616) 2023-07-11 16:36:42 +05:30
Guido van Rossum 22988c323a
gh-106529: Implement POP_JUMP_IF_XXX uops (#106551)
- Hand-written uops JUMP_IF_{TRUE,FALSE}.
  These peek at the top of the stack.
  The jump target (in superblock space) is absolute.

- Hand-written translation for POP_JUMP_IF_{TRUE,FALSE},
  assuming the jump is unlikely.
  Once we implement jump-likelihood profiling,
  we can implement the jump-unlikely case (in another PR).

- Tests (including some test cleanup).

- Improvements to len(ex) and ex[i] to expose the whole trace.
2023-07-10 16:04:26 -07:00