Commit Graph
31 Commits
Author SHA1 Message Date
Jeong, YunWon a1ba6a662c Align compiler and AST behavior with CPython (#8138)
* Align compiler and AST behavior with CPython

Update the compiler pipeline, AST module support, and related VM compile/eval paths toward CPython 3.14 behavior.

Use upstream Ruff parser crates directly and keep RustPython-specific syntax preflight handling in the compile path.

Refresh opcode metadata, snapshots, and targeted tests for the aligned bytecode and AST behavior.

* fix

* Fix PR 8138 CI failures

* Fix match mapping wildcard scan complexity

* fixes

* Use Ruff runtime AST fields

* Minimize residual patch diff

* refactor error handling

* Remove _ast conversion context wrappers

* Clean up _ast conversion glue and compiler warning escalation

Rename the Node conversion parameter `ctx` to `vm` throughout the _ast
module.

Remove the unused compile_program, compile_program_single,
compile_block_expression, and compile_expression forwarders; compile_top
stays as the entry point.

Stash an escalated compiler SyntaxWarning so a non-SyntaxWarning category
propagates unchanged instead of being rewritten to SyntaxError, matching
PyErr_ExceptionMatches(SyntaxWarning) in compiler_warn. Drop the now-unused
CompileWarningError::into_codegen_error.

Replace the PositionalArguments two-variant enum with a struct holding a
shared range and a PositionalArgumentsKind enum.

Assisted-by: Claude

* Represent compiler flags as a CompilerFlags bitflags

Replace the loose PY_CF_*/CO_* i32 constants in compile_mode with a
CompilerFlags bitflags covering the PyCF_* flags and __future__
CO_FUTURE_* bits. The Python-visible ast.PyCF_* attribute values are
derived from it via bits(); parser input modes stay plain consts.

builtins::compile and the compile_string flag handling test flags
through CompilerFlags::contains instead of raw bit math.

Assisted-by: Claude

* Fix PR 8138 test regressions

* Fix PR 8138 CI failures

* Avoid shell interpolation in Linux deps action

* Fix review findings in compiler/AST changes

- frame.rs: compute the MATCH_CLASS class name lazily so a successful
  match no longer takes the type name lock or allocates; the
  __match_args__-not-a-tuple branch reuses it instead of recomputing.
- _ast/constant.rs: add the missing leading space to the with_recursion
  label ("maximum recursion depth exceeded during compilation").
- sys.set_int_max_str_digits: restore the "maxdigits must be 0 or larger
  than {n}" error text.
- codegen: set CO_MAXBLOCKS to 20 in both ir.rs and compile.rs.
- _ast/exception.rs: extract the duplicated excepthandler node guard
  into ensure_excepthandler_node.
- codegen: correct the validate_keywords doc comment.
- Drop redundant "CPython" qualifiers from comments added in this branch.

Assisted-by: Claude
2026-06-26 18:22:08 +09:00
Shahar Naveh 620faab734 Update some tests to 3.14.5 (#7990)
* Update `test_embed.py` to 3.14.5

* Update `test_cmd_line*` to 3.14.5

* Update unicode related tests

* Update `test_script_helper.py`

* Update `test_gc.py`
2026-05-30 20:16:10 +09:00
Jeong, YunWonandCPython Developers 3df178298a Fix traceback, syntax errors, and exception handling (#7015)
* Update codeop from v3.14.3

* Fix traceback, syntax errors, and exception handling

- Improve unclosed bracket detection with "'(' was never closed" message
- Fix IndentationError location to point to end of line
- Implement frame.clear() with proper checks for executing/suspended frames
- Fix exception context chaining for propagated exceptions
- Add traceback.__dir__() and prevent tb_next deletion
- Fix subscript operation source range restoration in compiler
- Change "duplicate parameter" to "duplicate argument" error message
- Refactor duplicate code in asyncgenerator.rs and frame.rs

---------

Co-authored-by: CPython Developers <>

Assisted-by: Codex:gpt-6
2026-02-07 13:41:45 +09:00
Jeong, YunWon fea26e456f impl more nt (#6984)
* mpl new features

* windows encodings

* impl nt functions

* revert

* codecs

* fix codecs
2026-02-04 09:53:02 +09:00
Jeong, YunWon bdf3b3654e fix syntaxerror ast end_offset (#6646) 2026-01-05 08:01:41 +09:00
Jeong, YunWon 7f4d308efc Implement maybe_pyc_file and .pyc file execution (#6539)
* Implement maybe_pyc_file and .pyc file execution

* unmark failing tests
2025-12-26 22:13:00 +09:00
Jeong, YunWon 57b4b4ae45 fix sys path (#6537) 2025-12-26 21:43:00 +09:00
Copilotandyouknowone 6dbc8f0cfa Set SourceFileLoader for script execution in run_simple_file (#6496)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: youknowone <69878+youknowone@users.noreply.github.com>
2025-12-25 10:33:22 +09:00
Noa a86126419c Fix remaining tests 2025-03-25 19:05:12 -05:00
Noa ba1b5811ee Update encoding to use wtf8 2025-03-25 19:05:11 -05:00
NakanoMiku 9a61716f74 Edit test_cmd_line_script.py 2023-11-30 19:52:25 +08:00
NakanoMiku 700f2b9c12 Update test_cmd_line_script.py from CPython v3.12.0 2023-11-30 19:49:27 +08:00
Andrey MaltsevandJim Fasarakis-Hilliard 94dc7bb279 Apply suggestions from code review
Co-authored-by: Jim Fasarakis-Hilliard <d.f.hilliard@gmail.com>
2023-04-02 18:25:21 +03:00
Andrey Maltsev cde5527c9f fix mac os 2023-04-02 15:19:02 +00:00
Andrey Maltsev e169d97713 Update test_cmd_line_script from Cpython v3.11.2 2023-04-02 12:51:55 +00:00
Jeong YunWon 6ee827bd8a Fix CR/LF of python libraries 2023-02-28 17:11:41 +09:00
Jeong YunWon 53ef2b9a0a remove failure markers from test_imp,test_zipimport,test_cmd_line_script 2022-08-15 20:09:34 +09:00
CPython Developers 628c4c0edf Update runpy from CPython 3.10.6 2022-08-15 01:08:58 +09:00
Jeong YunWon 2fbd01f23e Fix surrogateescape_errors 2022-07-25 04:10:59 +09:00
Myeongseon Choi 44004935b0 Specify expectedFailure of test_non_ascii in Lib/test/test_cmd_line_script.py 2022-07-14 05:50:00 +09:00
Myeongseon Choi 5ab55dc7ce Add expectedFailure tag to test_non_ascii 2022-07-14 05:50:00 +09:00
Myeongseon Choi 9f29dc558a Update Lib/test/test_cmd_line_script.py to be runable 2022-07-14 05:50:00 +09:00
Myeongseon Choi e86a1bc92f Copy Lib/test/test_cmd_line_script.py from CPython v3.10.5 2022-07-14 05:50:00 +09:00
Dean Li 6f98288e84 test: use import_helper 2021-11-29 21:03:02 +08:00
Dean Li 5ee4fb899b test: use os_helper 2021-11-28 20:51:32 +08:00
Jeong YunWon 913b78ca44 Revert "Merge pull request #3433 from deantvv/test-update"
This reverts commit 9fa5c5ac66, reversing
changes made to e7fa32c687.
2021-11-17 17:06:51 +09:00
Dean Li 49a5805d11 test: use os_helper 2021-11-13 02:18:33 +00:00
Padraic Fanning 3865af44d1 Clean up skips in test_cmd_line_script 2021-10-10 19:11:23 -04:00
Padraic Fanning c3221a0d7b Unmark passing tests 2021-10-01 19:39:57 -04:00
snowapril 4014b91780 add decorators on failed & error tests
Signed-off-by: snowapril <sinjihng@gmail.com>
2021-10-01 14:10:58 +09:00
snowapril 2432c784c3 add test_cmd_line_script.py from cpython 3.8
Signed-off-by: snowapril <sinjihng@gmail.com>
2021-10-01 14:10:58 +09:00