unsloth/unsloth_cli/commands
Daniel Han 3fd948eb95
Pin utf-8 on shipping-code text I/O instead of the operator locale (#7486)
* Pin utf-8 on shipping-code text I/O instead of the operator locale

113 read_text/write_text/open call sites across unsloth, studio and
unsloth_cli let locale.getencoding() decide the encoding. That is utf-8 on
the Linux and macOS runners and cp1252 on a stock Windows install, so the
same file decodes differently for a Windows user and silently produces
mojibake or raises UnicodeDecodeError.

Adds tests/test_runtime_text_encoding.py to keep it that way. It resolves
openers through each file's own imports rather than a fixed list of module
names, so an aliased tarfile.open or a local from PIL.Image import open is
not asked for an encoding it does not take.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Scan tracked files only and resolve the unbound Path calling forms

* Honour PEP 263 when scanning sources and migrate a legacy JSONL before appending

* Scope guard imports lexically and only migrate a legacy file when it round-trips

* Leave a legacy JSONL untouched and resolve path aliases in the foreign-opener check

* Tighten comments

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-07-27 02:14:20 -07:00
..
__init__.py Rename cli/ to unsloth_cli/ to fix namespace collision with stringzilla (#4393) 2026-03-17 20:40:21 -07:00
_password_prompt.py Studio: reject whitespace-only passwords (#7341) 2026-07-23 00:44:37 -07:00
chat.py Fix local CLI streamed generation error handling (#7135) 2026-07-20 23:14:58 -03:00
export.py Formatting: ruff line-length 100, kwarg-spacing passes, drop blank after short local imports (#6079) 2026-06-08 04:24:13 -07:00
inference.py Fix local CLI streamed generation error handling (#7135) 2026-07-20 23:14:58 -03:00
start.py Add interactive Agents command builder (#7312) 2026-07-26 17:09:19 -07:00
studio.py Pin utf-8 on shipping-code text I/O instead of the operator locale (#7486) 2026-07-27 02:14:20 -07:00
train.py Add MLX backend support for CLI unsloth train (#6709) 2026-07-08 03:25:26 -07:00