Bug with Cyrillic in gcode comments

Basic Information:

Printer Model: voron switchwire
MCU / Printerboard: skr3ez
klippy.log

Describe your issue:

If the file code or comments contain Cyrillic, this creates a problem. For example, the file contains a material with a Cyrillic name; at 100% printing, because of this comment, the end_print macro does not work because the firmware goes into error

; filament_settings_id = "FDPlast TPU Веном"

if I fix name to english — all will work fine

; filament_settings_id = "FDPlast TPU venom"
Unhandled exception during run
Traceback (most recent call last):
  File "/home/pi/klipper/klippy/klippy.py", line 217, in run
    self.reactor.run()
  File "/home/pi/klipper/klippy/reactor.py", line 292, in run
    g_next.switch()
  File "/home/pi/klipper/klippy/reactor.py", line 340, in _dispatch_loop
    timeout = self._check_timers(eventtime, busy)
  File "/home/pi/klipper/klippy/reactor.py", line 158, in _check_timers
    t.waketime = waketime = t.callback(eventtime)
  File "/home/pi/klipper/klippy/extras/virtual_sdcard.py", line 261, in work_handler
    next_file_position = self.file_position + len(line.encode()) + 1
UnicodeEncodeError: 'ascii' codec can't encode characters in position 38-42: ordinal not in range(128)
Transition to shutdown state: Unhandled exception during run

klippy.log (855.3 KB)

prokladka_0.2mm_FLEX_Switchwire.gcode (471.2 KB)

It’s a known problem Internal error on command:"SDCARD_PRINT_FILE" · Issue #4794 · Klipper3d/klipper · GitHub

Yes, I saw this issue, but before updating the version to 0.12, comments in Cyrillic did not cause such problems.

; generated by PrusaSlicer 2.5.2+MacOS-x64 on 2023-06-16 at 07:46:08 UTC
...
; filament_settings_id = "FDPlast PETG Черный ворон"

UPD:

I have two printers

skr 3 ez

  • fluidd v1.28.1
  • klipper v0.12.0-114-ga77d0790
  • Klipper-Adaptive-Meshing-Purging v1.1.2-10-g093c57bf
  • moonraker v0.8.0-318-g9813011d
  • mcu v0.12.0-113-g28f06a10

and

manta m8p 1.1

  • fluidd v1.28.1
  • klipper v0.12.0-114-ga77d0790
  • Klipper-Adaptive-Meshing-Purging v1.1.2-10-g093c57bf
  • mainsail v2.10.0
  • moonraker v0.8.0-318-g9813011d
  • mcu v0.12.0-85-gd785b396

with second printer, I don’t have any problems with Cyrillic in comments
But on second printer I have configuration

[virtual_sdcard]
path: ~/printer_data/gcodes
on_error_gcode: CANCEL_PRINT

UPD2

I turned off the setting on the second printer. I added a comment in Cyrillic as the second line in gcode and the second printer ignored it. The first one with the same comment went into error

1 Like

Just don’t use gcode with non-ascii characters and you’ll be fine :wink:

Python: ‘2.7.18 (default, Jul 14 2021, 08:11:37) \n[GCC 10.2.1 20210110]’

Python 2 has no upstream support since 2020 (Sunsetting Python 2 | Python.org), and among other deficiencies does not handle unicode characters the same way as Python 3. I would recommend using a more recent version of Python for your Klipper install.

Just don’t use gcode with non-ascii characters and you’ll be fine :wink:

this is not a solution

I would recommend using a more recent version of Python for your Klipper install.

I’ll check it, thanks

I would recommend using a more recent version of Python for your Klipper install.

After upgrade python — problem gone.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.