Invoking a Talon script where the right hand side is a simple string including unicode characters which span more than one byte throws a TypeError: must be a unicode string of length 1. Wrapping the string with a call to user.paste works around the issue.
Repro
- Create a new Talon script in the
user folder with the following content:
emoji eyes: "👀"
- Open the Talon log
- Invoke the
emoji eyes command
- Observe the error in the log
Full traceback
talon.scripting.talon_script.TalonScriptError:
in script at C:\Users\danny\AppData\Roaming\talon\user\misc\emojis.talon:0:
> auto_insert('👀')
TypeError: must be a unicode string of length 1
2021-04-23 11:05:29 DEBUG [~] C:\Users\danny\AppData\Roaming\talon\user\misc\emojis.talon
2021-04-23 11:05:53 ERROR 14: talon\scripting\talon_script.py:518|
13: talon\scripting\talon_script.py:264|
12: talon\scripting\talon_script.py:485|
11: talon\scripting\actions.py:74 |
10: talon\scripting\types.py:359|
9: talon\scripting\core.py:333|
8: talon\scripting\actions.py:74 |
7: talon\scripting\types.py:359|
6: talon_plugins\main.py:34 | actions.key(c)
5: talon\scripting\actions.py:74 |
4: talon\scripting\types.py:359|
3: talon_plugins\main.py:71 | ctrl.key_press(keyname, **kwargs)
2: talon\windows\ctrl.py:230|
1: talon\windows\ctrl.py:184|
TypeError: must be a unicode string of length 1
[The below error was raised while handling the above exception(s)]
2021-04-23 11:05:53 ERROR cb error topic="phrase" cb=<bound method SpeechSystem.engine_event of <talon.scripting.speech_system.SpeechSystem object at 0x000000000CBDF270>>
30: threading.py:912 * # cron thread
29: threading.py:954 *
28: threading.py:892 *
27: talon\cron.py:123 |
26: talon\cron.py:83 |
25: talon\vad.py:21 |
24: talon\scripting\speech_system.py:303 |
23: talon\engines\w2l.py:1057|
22: talon\scripting\dispatch.py:103 |
21: talon\scripting\dispatch.py:138 |
20: talon\scripting\dispatch.py:129 |
19: talon\scripting\rctx.py:225 | # 'phrase' main:_redispatch()
18: talon\scripting\speech_system.py:52 |
17: talon\scripting\dispatch.py:103 |
16: talon\scripting\dispatch.py:138 |
15: talon\scripting\dispatch.py:129 |
14: -------------------------------------# cron thread
13: talon\scripting\rctx.py:225 | # 'phrase' main:engine_event()
12: talon\scripting\speech_system.py:353 |
11: talon\scripting\actions.py:74 |
10: talon\scripting\types.py:359 |
9: talon\scripting\core.py:108 |
8: talon\scripting\actions.py:74 |
7: talon\scripting\types.py:359 |
6: talon\scripting\core.py:138 |
5: talon\scripting\actions.py:74 |
4: talon\scripting\types.py:359 |
3: talon\scripting\core.py:143 |
2: talon\scripting\talon_script.py:615 |
1: talon\scripting\talon_script.py:522 |
talon.scripting.talon_script.TalonScriptError:
in script at C:\Users\danny\AppData\Roaming\talon\user\misc\emojis.talon:1:
> auto_insert('👀')
TypeError: must be a unicode string of length 1
Invoking a Talon script where the right hand side is a simple string including unicode characters which span more than one byte throws a TypeError:
must be a unicode string of length 1. Wrapping the string with a call touser.pasteworks around the issue.Repro
userfolder with the following content:emoji eyes: "👀"emoji eyescommandFull traceback