Commit Graph
48 Commits
Author SHA1 Message Date
chestnut1717 d6161ac321 Fix EOF SyntaxError diagnostics (#8429)
* Fix EOF SyntaxError diagnostics

* Fix Scope EOF SyntaxError location conversion

* Fix Additional Unexpected Test

* Docs Add Annotation source_location_in_code_points()
2026-08-09 14:58:53 +09:00
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 b28f29313f Update some tests to 3.14.6 (#8167)
* Add `test_fileutils.py` from 3.14.6

* Align patch for `test_zipimport_support.py`

* Update `test_bigmem.py` to 3.14.6

* Update `test_exception_group.py`

* Align patches for `test_baseexception.py`

* Update `test_exceptions.py`

* Update `test_dtrace.py`

* Remove patch from `string_tests.py`
2026-06-25 22:33:51 +09:00
Jeong, YunWon 6440e64355 Align codegen metadata with CPython (#7952) 2026-05-23 20:16:03 +09:00
Huy Vũ (Josh) 5e989f00e9 Validate SyntaxError details tuple shape (#7533) 2026-03-29 22:37:08 +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
CPython Developers 8265279411 Update test_exceptions from v3.14.2 2026-01-31 00:59:29 +09:00
Jeong, YunWon 7eceb145b1 more optimization (#6860) 2026-01-25 10:18:47 +02:00
Jeong, YunWon eee360822c Rework compiler about exception handling (#6638)
* asyncgen

* fix coroutine

* rewrite compiler

* tests

* set pyc magic number
2026-01-04 09:15:38 +09:00
Jeong YunWon 4a352344b6 mark failing test_ctypes 2025-12-24 00:13:30 +09:00
Jiseok CHOI 9ce85862ce Add BaseException.add_note() and __notes__ attribute support (#6252) 2025-11-14 10:31:47 +09:00
ShaharNaveh 68e7310d22 reapply patch 2025-10-22 11:02:36 +03:00
ShaharNaveh e18354b990 fix test markers in test_exceptions.py 2025-10-22 10:57:47 +03:00
ShaharNaveh 19b6241ef9 Update changed files from 3.13.7 -> 3.13.8 2025-10-22 10:57:47 +03:00
ShaharNaveh f6d755b4ff mark failing tests 2025-07-16 13:37:18 +03:00
ShaharNaveh 0fbe6ce268 Update test_exceptions from 3.13.5 2025-07-16 13:37:18 +03:00
Jeong, YunWon 3734f32e42 Exception.set_traceback_typed (#5832) 2025-06-24 18:56:10 +09:00
Jeong, YunWon 9c2a4695c1 Fix excepthook (#5830) 2025-06-24 16:58:27 +09:00
Jeong YunWon e4c8f2bb43 Fix ImportError 2025-06-20 16:12:30 +09:00
Jeong YunWon 44d66dcdac Fix SyntaxError 2025-06-20 16:12:30 +09:00
Jeong YunWon a186a5a9f5 Impl PyAttributeError args 2025-06-18 15:53:17 +09:00
a6b4ef7f5d Replace Python parser with ruff parser (#5494)
* stage1

* compiler pass build

* introduce rustpython-compiler-source

* stage2

* fixup

* pass compile

* Fix hello world compiler test

* Fix code generation for if-elif-else statement

* Fix code generation for lambda expression

* Fix code generation for integers

* Fix code generation for fstrings

* Fix code generation for if statement

* Fix code generation for if statement

* Fix code generation for if statement

* Fix code generation for fstring

* Fix code generation for class definition

* Replace feature flags

* Initialize frozen core modules

* Allow __future__ import after module doc comment

* Disable ast module

* Commit remaining fixes for compile errors in examples

* Fix some warnings

* Update ast stdlib module

* Update ast stdlib module

* Update ast stdlib module

* Update ast stdlib module

* Update ast stdlib module

* Split ast stdlib module into files

* Fix codegen for positional arguments with defaults

* Update ast stdlib module

* Update ast stdlib module

* Extract string and constant handling from expression.rs

* Always add required fields to AST nodes

* Compile doc strings correctly again

* Enable "ast" Cargo feature by default

* Refactor compilation of big integer literal

* Update ast stdlib module

* Update ast stdlib module

* Update ast stdlib module

* Reset barebones example

* Fix some left-over warnings

* Undo accidential change

* Adapt shell to ruff parser

* Pin parser to v0.4.10

* fix clippy

* Add TODO about interactive mode

* Fix compilation of complex number expression

* Remove moved code

* Update test case to ruff v0.4.10

* Apply suggestion

Co-authored-by: Jeong, YunWon <69878+youknowone@users.noreply.github.com>

* Apply suggestion

Co-authored-by: Jeong, YunWon <69878+youknowone@users.noreply.github.com>

* Fix compilation of fstring expression

* Fix compilation of fstring expression

* Fix wasm compile errors

* Attach correct source locations to ast objects

* Fix some more wasm compile errors

* Consider compile mode and enable AST stdlib module again

* Fix incorrect AST source location end column

* Fix compile error if "compiler" feature is not enabled

* Fix regrtests

* Fix some test_ast tests

* Add source range to type ignore

* Fix incompatibility with Rust 2024 edition

* Fix todos by implementing missing ast conversions and deleting unused code

* Appease clippy

* Fix remaining ast tests

* Fix remaining ast tests

* Mark/fix remaining tests

* Fix more

* Hacky windows fix

---------

Co-authored-by: Kangzhi Shi <shikangzhi@gmail.com>
Co-authored-by: Jeong YunWon <jeong@youknowone.org>
Co-authored-by: Jeong, YunWon <69878+youknowone@users.noreply.github.com>
Co-authored-by: Noa <coolreader18@gmail.com>
2025-03-19 21:06:03 -05:00
Ankit Goel 7623668256 Raise TypeError if BaseException receives Keyword arguments 2024-09-24 11:57:37 +09:00
Jonathan Rotter 1034477f1e unit test fix - only allow catching exceptions - test_catch_non_BaseException (#5249)
* test_baseexception.test_catch_non_BaseException

* enabling test_except_star_invalid_exception_type
2024-04-21 01:30:20 +09:00
Andrey Maltsev 302149e02d Update test_exceptions.py from Cpython v3.11.2 2023-04-02 14:35:18 +00:00
Riley Sutton 83880893d5 Enable previously failing tests 2022-12-27 18:06:56 +11:00
Jeong YunWon 15aad7cb94 Fix with-statement location 2022-08-11 07:14:20 +09:00
Jeong YunWon a363b05340 PySetterValue for descr_set and setattro 2022-08-08 04:31:14 +09:00
Myeongseon Choi 43824e393b Change Lib/test/test_exceptions.py runable 2022-07-13 16:47:31 +09:00
Myeongseon Choi 4030ad12d9 Update test_exceptions.py from CPython 3.10.5 2022-07-13 16:47:31 +09:00
Padraic Fanning 2815f3d037 Unmark passing test 2022-04-27 20:40:06 -04:00
Dean Li 29c953d9a6 test: update test.support and test_io to 3.10
Initially this is only meant to be a small update for `test_io.py`.
But it turns out that `test.support` need a lot of cleanup especially
for `test.support.warnings_helper`.
2022-04-18 22:50:55 +08: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
snowapril 1bff6a38d1 add decorators on failed tests
Signed-off-by: snowapril <sinjihng@gmail.com>
2021-10-20 10:19:42 +09:00
snowapril 8d0cefeb64 update test_exceptions.py from cpython 3.10 for suggestion feature
Signed-off-by: snowapril <sinjihng@gmail.com>
2021-10-20 10:19:42 +09:00
Noah 0ab451c519 Rework the vm exception stack to handle errors better 2021-02-15 17:44:48 -06:00
Noah 99a8d68933 Fix test_exceptions.testRaising 2020-12-19 15:09:20 -06:00
Jeong YunWon 2970af237a unskip test_exceptions.py 2020-11-12 11:30:33 +09:00
Basix 9868f63f50 Skip CPython-specific test on Windows
Check its comments for details
2020-08-10 02:36:29 +09:00
Basix e5178574f0 Skip rescursion tests on Windows
See #2050
2020-08-10 02:36:29 +09:00
Aviv Palivoda 77b83ea4f8 Separate coro exception stack 2020-03-06 12:04:40 +02:00
Aviv Palivoda 83386fda25 Set errno on os.listdir 2020-03-06 10:46:29 +02:00
Aviv Palivoda 92d0f05242 Mark unsupported tests 2020-03-06 10:46:29 +02:00
Aviv Palivoda 78565d1ab0 Add test_exceptions from CPython 3.8 2020-03-06 10:46:29 +02:00