robotframework-stacktrace icon indicating copy to clipboard operation
robotframework-stacktrace copied to clipboard

UnicodeEncodeError

Open amitlohar opened this issue 2 years ago • 6 comments

We have multibyte chars in our test cases like _平 ^~ŸÁ&. In log files we have been seeing error-

Calling method 'end_keyword' of listener 'RobotStackTracer' failed: UnicodeEncodeError: 'charmap' codec can't encode character '\u5e73' in position 659: character maps to <undefined>

I don't see any major effect of this though, but since it is logged in our every run thought of reporting.

amitlohar avatar Feb 08 '23 11:02 amitlohar

Can you give me a reproducible example?

Please also specify the environment: Windows Version: Python Version: Which Terminal are you using?

Snooz82 avatar Mar 04 '23 17:03 Snooz82

https://robotframework.slack.com/archives/C07PJBN64/p1677798947815299

Same error appears with an other user. Still no possibility to reproduce for me

Snooz82 avatar Mar 04 '23 17:03 Snooz82

This happens on windows server. We execute our runs from TeamCity so the terminal should be windows command prompt. I will check if I can create a dummy test to reproduce this and will post soon.

amitlohar avatar Mar 08 '23 05:03 amitlohar

We can reproduce!

in the slack thread there is the fix. I just had no time yet to fix it

Snooz82 avatar Mar 08 '23 06:03 Snooz82

Could you copy the solution here from slack since i have no access to that slack thread? Thanks in advance!

ish91 avatar Oct 18 '24 08:10 ish91

this is from slack

If you change line 127 in init.py of RobotStackTracer to print(console_encode("\n".join(self._create_stacktrace_text()))) and change line 20 to from robot.utils import cut_long_message, console_encode Then you have a fix

You will not see the ✖️ character but you will get a ?

Snooz82 avatar Oct 18 '24 09:10 Snooz82