You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
UnicodeEncodeError crash on Windows (cp1252) from Rich spinner characters #91
smpmgr upgrade crashes with UnicodeEncodeError on Windows when the console codepage is cp1252 (the default for most Western Windows systems). The Rich library's braille spinner character \u2819 cannot be encoded in cp1252, causing the entire upgrade to abort even though the upload may have started.
smpmgr crashes during the progress spinner display
Expected Behavior
The upload should complete without crashing. The progress display should use characters compatible with the console encoding, or smpmgr should set PYTHONIOENCODING=utf-8 / handle encoding gracefully.
Actual Behavior
UnicodeEncodeError: 'charmap' codec can't encode character '\u2819' in position 0: character maps to <undefined>
Full traceback (trimmed):
File "...\rich\_win32_console.py", line 441, in write_styled
self.write_text(text)
File "...\rich\_win32_console.py", line 402, in write_text
self.write(text)
File "...\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)
UnicodeEncodeError: 'charmap' codec can't encode character '\u2819' in position 0: character maps to <undefined>
The crash originates in Rich's LegacyWindowsTerm when rendering the braille spinner (\u2819).
Workaround
Setting PYTHONIOENCODING=utf-8 before running smpmgr avoids the crash, though spinner characters render as mojibake:
set PYTHONIOENCODING=utf-8
py -m smpmgr --port COM14 upgrade firmware.signed.bin
Environment
OS: Windows 11 Pro 10.0.26200
Python: 3.12.7
smpmgr: 0.17.0
smpclient: 6.1.0
smp: 4.0.2
Console codepage: cp1252 (Western European, Windows default)
Thanks! I've never heard of console code page, what is that? Generally, it should work without any configuration in both flavors of PowerShell, and probably command prompt, but I would recommend either flavor of PowerShell over that.
I've been using claude code to do some automatic PID tuning on our soldering irons, and it needs to re-load firmware regularly, so I don't fully understand why claude would fail running smpmgr in powershell when running smpmgr directly in powershell hadn't ever failed before. Here is the response claude provided when I asked it to answer your questions
The "console code page" is the Windows legacy encoding that Python uses for stdout by default — on most Western Windows systems
it's cp1252 (Windows-1252). You can check it with python -c "import sys; print(sys.stdout.encoding)" or chcp in cmd. It's
separate from the terminal itself — it's the encoding Python picks up from locale.getpreferredencoding().
I hit this running smpmgr from a Python subprocess (subprocess.run with capture_output=True) on Windows 11 with Command Prompt
as the underlying shell. But the encoding is cp1252 regardless of whether I use Command Prompt, PowerShell, or Windows Terminal
— it's the system-level ANSI code page, not a terminal setting. sys.stdout.encoding reports cp1252 in all of them on this
machine.
The Rich issue you linked (#2882) looks like the same root cause. Good news that PEP 686 will default to UTF-8 in 3.15 — that
should fix it for good. In the meantime, PYTHONIOENCODING=utf-8 works as a workaround on our end.
OK, so it sounds like the fix is for that environment variable to get set in the subprocess API.
Since you're in a python program already, you can get a lot more flexibility by using smpclient directly. You could start by pointing Claude at these excerpts:
Activity
JPHutchins commentedon Feb 13, 2026
Thanks! I've never heard of console code page, what is that? Generally, it should work without any configuration in both flavors of PowerShell, and probably command prompt, but I would recommend either flavor of PowerShell over that.
Possible root cause: Textualize/rich#2882
What terminal are you using?
JPHutchins commentedon Feb 13, 2026
Looks like PEP 686 will make this default in 3.15: https://peps.python.org/pep-0686/
brettlhartt commentedon Feb 13, 2026
I've been using claude code to do some automatic PID tuning on our soldering irons, and it needs to re-load firmware regularly, so I don't fully understand why claude would fail running smpmgr in powershell when running smpmgr directly in powershell hadn't ever failed before. Here is the response claude provided when I asked it to answer your questions
JPHutchins commentedon Feb 13, 2026
OK, so it sounds like the fix is for that environment variable to get set in the subprocess API.
Since you're in a python program already, you can get a lot more flexibility by using smpclient directly. You could start by pointing Claude at these excerpts:
smpmgr/smpmgr/main.py
Lines 145 to 237 in d38b401
smpmgr/smpmgr/image_management.py
Lines 142 to 172 in d38b401
JPHutchins commentedon May 21, 2026
I think that the workarounds in here are good. Also, python is going to default on next release https://docs.python.org/3.15/whatsnew/3.15.html#whatsnew315-utf8-default
fix: draw the spinner in ASCII when the console can't encode braille
fix: never crash on output the console's encoding cannot represent
JPHutchins commentedon Nov 11, 2026
Warning
LLM Disclosure
This post was authored by claude-opus-5-5 on behalf of @JPHutchins. JP asked for each fixed issue to link the release that shipped it.
Released in smpmgr 0.20.2 (#104).