Commit Graph
148 Commits
Author SHA1 Message Date
Jeong, YunWon 0f8f6ee3c0 Replace std::sync::LazyLock with common::lock::LazyLock (#7079) 2026-02-11 16:09:42 +09:00
ShaharNaveh 6a73411960 impl array.clear 2026-02-10 12:58:29 +02:00
Jeong, YunWon b6e7d71e2e Remove static cache for builtins iter/reversed reduce
- Replace static_cell! cached builtins_iter/builtins_reversed with
  per-call vm.builtins.get_attr lookups to support runtime builtins
  mutation (CPython issue #101765)
- Refactor PositionIterInternal::reduce to take func, active, and
  empty callbacks; resolve builtins outside the lock to prevent
  deadlock from reentrant iterator access
- Add __reduce__ and fix reentrant next() in PyCallableIterator
- Remove expectedFailure from test_reverse_iterator_picking and
  test_reduce_mutating_builtins_iter
2026-02-10 00:49:12 +09:00
Jeong, YunWon bc4e396bf6 Replace unsafe pointer cast with PyMutex in PyCode (#7055)
Add `source_path: PyMutex<&'static PyStrInterned>` field to
`PyCode` for interior mutability, replacing the UB-inducing
`#[allow(invalid_reference_casting)]` + `write_volatile` pattern
in `update_code_filenames`. Update all read sites across the
codebase to use the new `source_path()` accessor method.
2026-02-09 14:01:39 +09:00
Jeong, YunWonandgithub-actions[bot] b877f76141 initial sandbox (#7035)
* Add host_env feature for sandbox isolation

Introduce a `host_env` feature flag that gates all host environment
access (filesystem, network, signals, processes). When disabled,
the VM operates in sandbox mode:

- _io module always available; FileIO gated by host_env
- SandboxStdio provides lightweight stdin/stdout/stderr via Rust std::io
- BytesIO/StringIO/BufferedIO/TextIOWrapper work without host_env
- open() returns UnsupportedOperation in sandbox
- stdlib modules (os, socket, signal, etc.) gated by host_env
- CI checks both host_env ON and OFF builds

* Auto-format: ruff check --select I --fix

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-02-08 13:58:30 +00:00
Jeong, YunWon a5fc3a82de reason inside #[allow] (#7049) 2026-02-08 13:11:50 +00:00
Jeong, YunWon 9d563ce168 no_std clippy (#7043) 2026-02-08 16:49:18 +09:00
Jeong, YunWon 654a3eab8c Implement more warnings 2026-02-05 23:50:08 +09:00
Jeong, YunWon 6561fb12da align overlapped to CPython 3.14.2 (#7005) 2026-02-05 23:38:35 +09:00
dependabot[bot] 1d9bb0f54c Bump flate2 from 1.1.8 to 1.1.9 (#6991)
* Bump flate2 from 1.1.8 to 1.1.9

Bumps [flate2](https://github.com/rust-lang/flate2-rs) from 1.1.8 to 1.1.9.
- [Release notes](https://github.com/rust-lang/flate2-rs/releases)
- [Commits](https://github.com/rust-lang/flate2-rs/compare/1.1.8...1.1.9)

---
updated-dependencies:
- dependency-name: flate2
  dependency-version: 1.1.9
  dependency-type: direct:production
  update-type: version-update:semver-patch
...
2026-02-04 14:30:59 +09:00
Jeong, YunWon e3b61994cc Remove _use_vfork 2026-02-04 11:15:58 +09:00
Jeong, YunWon db45c07e77 rework SchedParam 2026-02-03 22:10:31 +09:00
Jeong, YunWon 279f33a407 fix timeout 2026-02-03 22:10:31 +09:00
Jeong, YunWon 3b956c8733 Support #[cfg] in with (#6975) 2026-02-03 18:55:59 +09:00
Jeong, YunWon 527ae55a7a Update faulthandler to match CPython 3.14.2
- Rewrite faulthandler with live frame walking via
  Frame.previous AtomicPtr chain and thread-local
  CURRENT_FRAME (AtomicPtr) instead of frame snapshots
- Add signal-safe traceback dumping (dump_live_frames,
  dump_frame_from_raw) walking the Frame.previous chain
- Add safe_truncate/dump_ascii for UTF-8 safe string
  truncation in signal handlers
- Refactor write_thread_id to accept thread_id parameter
- Add SA_RESTART for user signal registration, SA_NODEFER
  only when chaining
- Save/restore errno in faulthandler_user_signal
- Add signal re-entrancy guard in trigger_signals to
  prevent recursive handler invocation
- Add thread frame tracking (push/pop/cleanup/reinit)
  with force_unlock fallback for post-fork recovery
- Remove expectedFailure markers for now-passing tests
2026-02-03 13:41:58 +09:00
Jeong, YunWon 4abf70ce09 Merge pull request #6942 from youknowone/os-fix
posix.link, termios.error, warn() error, closefd=False for std in/out
2026-02-02 08:11:46 +09:00
Jeong, YunWon 1cfa96cf02 Merge pull request #6902 from youknowone/asyncio
Update asyncio to 3.14.2
2026-02-02 08:04:52 +09:00
Jeong, YunWon d8e582ef6e _locale.localeconv (#6941) 2026-02-02 02:02:12 +09:00
Jeong, YunWon 188d438e00 Use new_os_subtype_error for termios error construction
- Replace manual exception creation with new_os_subtype_error in termios
- Remove redundant .to_owned() calls in os.link() error messages
2026-02-02 01:54:58 +09:00
Jeong, YunWon 5e732c5e2a Fix wasip2 build (#6935) 2026-02-02 01:26:17 +09:00
Jeong, YunWon fe40dd37c0 impl more _asyncio 2026-02-02 00:43:07 +09:00
Jeong, YunWon 5e4c3b07fb gc is vm/stdlib (#6929) 2026-02-01 13:21:24 +09:00
Jeong, YunWon 714d1ce58b gc module internal structure and API (#6910)
* gc module internal structure and API

Add gc_state module with GcState, GcGeneration, GcDebugFlags, GcStats.
Replace gc module stubs with working API backed by gc_state.
Add gc_callbacks and gc_garbage to Context.
Add is_gc_tracked, gc_finalized, gc_get_referents to PyObject.
Collection is stubbed (returns 0) — actual algorithm to follow.

* fix dict/weakref/generators

* unmark test_asyncio

* apply review
2026-02-01 08:51:39 +09:00
Shahar Naveh 743d6b83d3 Split stack_effect into pushed & popped (#6893) 2026-01-31 16:58:14 +09:00
Jeong, YunWon 050faa312a Fix _overlapped segfault and missing _winapi constants
- Fix from_windows_err using new_exception_empty on OSError subclasses
  (ConnectionRefusedError, ConnectionAbortedError), which caused segfault
  in release builds due to debug_assert on type size mismatch
- Move ConnectPipe from instance method to module-level function
- Add Destructor for Overlapped to cancel pending I/O on object cleanup
- Add NMPWAIT_NOWAIT, NMPWAIT_USE_DEFAULT_WAIT, NMPWAIT_WAIT_FOREVER
  constants to _winapi
2026-01-31 06:39:32 +09:00
Jeong YunWon d8fa1b4366 _asyncio rust impl 2026-01-29 16:48:33 +09:00
Jeong YunWon aaa86584e5 Add _asyncio 2026-01-29 16:48:33 +09:00
Jeong YunWon 2e0b76556a Add more socket consts 2026-01-29 16:48:33 +09:00
Jeong, YunWon e363b14e81 fix ssl MSG_PEEK (#6892) 2026-01-29 16:48:02 +09:00
Jeong, YunWon 0cc43e192c Implement Windows overlapped I/O for asyncio support
Add comprehensive Windows async I/O support to the overlapped module:

Winsock Extensions:
- Initialize AcceptEx, ConnectEx, DisconnectEx, TransmitFile via WSAIoctl
- Proper cleanup with all four extension locks checked

Overlapped Methods:
- ReadFile, ReadFileInto: Async file reading
- WriteFile: Async file writing
- WSARecv, WSARecvInto: Async socket receive
- WSASend: Async socket send
- WSARecvFrom, WSARecvFromInto: Async UDP receive with address
- WSASendTo: Async UDP send to address
- AcceptEx: Async socket accept
- ConnectEx: Async socket connect
- DisconnectEx: Async socket disconnect
- TransmitFile: Async file transmission over socket
- ConnectNamedPipe, ConnectPipe: Named pipe support

Module Functions:
- CreateIoCompletionPort: IOCP creation/association
- GetQueuedCompletionStatus: Dequeue completion packets
- PostQueuedCompletionStatus: Post completion packets
- RegisterWaitWithQueue: Register wait with completion port callback
- UnregisterWait, UnregisterWaitEx: Unregister waits with proper cleanup
- BindLocal: Bind socket to local address
- CreateEvent, SetEvent, ResetEvent: Event object management
- FormatMessage: Windows error message formatting

Safety & Correctness:
- Validate buffer contiguity before async operations
- Validate size parameters to prevent buffer overflow
- Use Arc for RegisterWaitWithQueue callback data to prevent UAF
  (callback may run after UnregisterWait returns per Windows API docs)
2026-01-28 16:56:47 +09:00
fanninpm 4c1c704bb1 Add ExpatError and error to pyexpat (#6889)
* Stub out xml.parsers.expat.ExpatError

* Alias `ExpatError` to `error`
2026-01-28 10:19:00 +09:00
Jeong, YunWon edca32a194 Fix ssl shutdown (#6871)
* Fix ssl shutdown

* Fix thread
2026-01-27 02:50:15 +09:00
dependabot[bot] 0dd73170e5 Bump openssl-probe from 0.2.0 to 0.2.1
Bumps [openssl-probe](https://github.com/rustls/openssl-probe) from 0.2.0 to 0.2.1.
- [Release notes](https://github.com/rustls/openssl-probe/releases)
- [Commits](https://github.com/rustls/openssl-probe/compare/0.2.0...0.2.1)

---
updated-dependencies:
- dependency-name: openssl-probe
  dependency-version: 0.2.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-26 23:47:39 +09:00
Jeong, YunWon 7eceb145b1 more optimization (#6860) 2026-01-25 10:18:47 +02:00
Jeong YunWon c0bdb9a3e5 align psuedo ops to 3.14.2 2026-01-24 16:09:40 +09:00
Jeong YunWon 771650a012 align HAVE_ARGUMENT 2026-01-24 16:09:40 +09:00
Jeong, YunWon efce325cbf Fix asyncio related compiler/library issues (#6837)
* Fix socket bytes support

* fix unwind_fblock

* fix posix.sendfile

* fix ssl_write

* Fix SSL ZeroReturn

* fix context

* fix generator

* Enable unittest test_async_case again
2026-01-23 19:59:29 +09:00
Jeong, YunWonandgithub-actions[bot] 125ade5f55 fix clippy 1.93.0 (#6836)
* fix clippy 1.93.0

* Auto-format: cargo fmt --all

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-01-23 02:18:39 +09:00
Jeong, YunWon 40a43f3210 instruction improvements (#6829)
New Features

Direct small-integer loading (0–255) and locals-loading for faster execution
Async-generator wrapping and improved generator resume behavior
Performance

Faster integer loads and streamlined jump/loop handling for better runtime performance
Bug Fixes

More robust StopIteration handling and stricter init return checks
Corrected iterator cleanup for async and sync loops
Improvements

Aligns loop and jump semantics with CPython 3.14 patterns
2026-01-22 17:25:56 +09:00
Jeong YunWon 20376451eb Implement Py_mod_create slot support in multi-phase init 2026-01-22 11:21:42 +09:00
Jeong YunWon bc02b2318c module_exec 2026-01-21 22:39:40 +09:00
Jeong YunWon 32d2406fa8 module_def 2026-01-21 22:39:40 +09:00
Jeong YunWon fee1a4b097 multiphase 2026-01-21 22:39:39 +09:00
Jeong, YunWon 2df879c5ee Fix Drop to prevent TLS data loss (#6825)
Remove pending_tls_output.clear() from Drop implementation.

SSLSocket._real_close() in Python doesn't call shutdown() before
closing - it just sets _sslobj = None. This means pending TLS data
in the output buffer may not have been flushed to the socket yet.
Clearing this buffer in Drop causes data loss, resulting in empty
HTTP responses (test_socketserver failure on Windows).

The explicit clearing is also unnecessary since all struct fields
are automatically freed when the struct is dropped.
2026-01-21 17:29:22 +09:00
Jeong, YunWon 274e8b4b6b Remove JUMP_IF_NOT_EXC_MATCH, SET_EXC_INFO (#6820) 2026-01-21 01:23:43 +09:00
Jeong, YunWon e0cceaf31c Remove ReturnConst/Break/Continue ops (#6816)
* Remove ReturnConst

* Remove break/continue ops
2026-01-21 00:03:43 +09:00
Jeong, YunWon f0c3e7d51f Remove SUBSCRIPT, JUMP_IF_{TRUE,FALSE}_OR_POP (#6810)
* Align ForIter behavior (incomplete)

* Romove JUMP_IF_{TRUE,FALSE}_OR_POP, subscript

* Remove LoadAssetionError

* Update snapshot for ForIter behavior change
2026-01-20 16:21:23 +09:00
Jeong, YunWon ef2c0a6d9d More FromArgs message (#6806) 2026-01-20 10:37:27 +09:00
Jeong, YunWon 6a064aad3b Drop for PySSLSocket (#6791) 2026-01-19 10:01:11 +09:00
Jeong, YunWon 130bb82a43 LoadClosure as pseudo op (#6789) 2026-01-19 02:45:00 +09:00