fix RFC module resolution on Windows

- normalize paths (backslashes are not dots) - fix winpty choking on dict env

Alessandro committed Oct 19, 2025 at 17:59 UTC 597648d1e894dc92470d715eed0c24d8904f96e7
2 files changed +7 -2
python/helpers/runtime.py
+4 -1
@@ -1,6 +1,7 @@
1 import argparse
2 import inspect
3 import secrets
4 +from pathlib import Path
5 from typing import TypeVar, Callable, Awaitable, Union, overload, cast
6 from python.helpers import dotenv, rfc, settings, files
7 import asyncio
@@ -82,7 +83,9 @@ async def call_development_function(func: Union[Callable[..., T], Callable[...,
83 if is_development():
84 url = _get_rfc_url()
85 password = _get_rfc_password()
85 - module = files.deabsolute_path(func.__code__.co_filename).replace("/", ".").removesuffix(".py") # __module__ is not reliable
86 + # Normalize path components to build a valid Python module path across OSes
87 + module_path = Path(files.deabsolute_path(func.__code__.co_filename)).with_suffix("")
88 + module = ".".join(module_path.parts) # __module__ is not reliable
89 result = await rfc.call_rfc(
90 url=url,
91 password=password,
python/helpers/tty_session.py
+3 -1
@@ -210,7 +210,9 @@ async def _spawn_winpty(cmd, cwd, env, echo):
210
211 cols, rows = 80, 25
212 pty = winpty.PTY(cols, rows) # type: ignore
213 - child = pty.spawn(cmd, cwd=cwd or os.getcwd(), env=env)
213 + # winpty expects env as None or list of "KEY=VALUE" strings, not a dict
214 + winpty_env = None if env is None else [f"{k}={v}" for k, v in env.items()]
215 + child = pty.spawn(cmd, cwd=cwd or os.getcwd(), env=winpty_env)
216
217 master_r_fd = msvcrt.open_osfhandle(child.conout_pipe, os.O_RDONLY) # type: ignore
218 master_w_fd = msvcrt.open_osfhandle(child.conin_pipe, 0) # type: ignore