Skip to content

Fix/utf8 stdout windows - #1360

Closed
QuiqueMH wants to merge 1 commit into
MemPalace:developfrom
QuiqueMH:fix/utf8-stdout-windows
Closed

Fix/utf8 stdout windows#1360
QuiqueMH wants to merge 1 commit into
MemPalace:developfrom
QuiqueMH:fix/utf8-stdout-windows

Conversation

@QuiqueMH

@QuiqueMH QuiqueMH commented May 5, 2026

Copy link
Copy Markdown

What does this PR do?

How to test

Checklist

  • Tests pass (python -m pytest tests/ -v)
  • No hardcoded paths
  • Linter passes (ruff check .)

Two non-ASCII characters in CLI print paths break on Windows consoles
whose default encoding is cp1252:

* `searcher.py:363` prints `'─' * 56` as the search-result divider.
  cp1252 cannot encode U+2500, so `mempalace search` raises
  UnicodeEncodeError mid-render and exits non-zero.
* `miner.py:1257` prints the `MemPalace Status —` header. cp1252
  *can* encode U+2014 (em-dash), but as the single byte 0x97 which is
  invalid UTF-8. Parent processes reading `mempalace status` as UTF-8
  fail to decode.

Reconfiguring sys.stdout/stderr to UTF-8 with errors="replace" at the
top of cli.py eliminates both — and the whole class of bug — without
touching the offending lines (which would only fix these two incidents).

reconfigure() exists on io.TextIOWrapper for Python 3.7+; the hasattr
guard is belt-and-braces for any future test harness that swaps in a
different stream type. errors="replace" prevents future regressions of
the same shape from crashing the process.

Programmatic users importing mempalace.searcher directly are
unaffected — the change is scoped to the CLI entry point.
@igorls igorls added bug Something isn't working area/windows Windows-specific bugs and compatibility labels May 6, 2026
@igorls
igorls changed the base branch from main to develop May 17, 2026 19:35
@igorls

igorls commented Jun 6, 2026

Copy link
Copy Markdown
Member

Thanks! Windows non-ASCII output is already addressed on develop via #1100 (ASCII glyphs) and #1102 (UTF-8 BOM). Closing as overlapping.

@igorls igorls closed this Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/windows Windows-specific bugs and compatibility bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants