Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hard crash in logger due to codec issues #6909

Closed
sanderland opened this issue Jun 1, 2020 · 1 comment
Closed

Hard crash in logger due to codec issues #6909

sanderland opened this issue Jun 1, 2020 · 1 comment

Comments

@sanderland
Copy link
Contributor

Software Versions

  • Python: 3.7
  • OS: Windows 10
  • Kivy: 2.0.0rc2
  • Kivy installation method: pypi

Describe the bug
When setting logging level to trace, _write_message can crash with a UnicodeError

Expected behavior
Never hard crash while logging.

Probably there is some issue with picking up the codec, but logging binary strings with a catch Exception: something went wrong would be better than the current behaviour.

To Reproduce
Have a Korean version of windows 10 (which has the default cp949 codec) and a function call which returns a utf-8 string with special characters in a kv file.

Code and Logs and screenshots

 kivy.lang.builder.BuilderException: Parser: File "C:\Users\sande\Desktop\katrain\katrain\popups.kv", line 56:
 ...
      54:<I18NPopup>:
      55:    background_color: [*[c*255/66 for c in BACKGROUND_COLOR[:3]], 1]
 >>   56:    title: i18n._(self.title_key)
      57:    title_size: DESC_FONT_SIZE
      58:    title_font: self.font_name
 ...

 UnicodeEncodeError: 'cp949' codec can't encode character '\xe8' in position 29: illegal multibyte sequence
   File "C:\Users\sande\Anaconda3\lib\site-packages\kivy\lang\builder.py", line 699, in _apply_rule
     setattr(widget_set, key, value)
   File "kivy\weakproxy.pyx", line 35, in kivy.weakproxy.WeakProxy.__setattr__
   File "kivy\properties.pyx", line 497, in kivy.properties.Property.__set__
   File "kivy\properties.pyx", line 544, in kivy.properties.Property.set
   File "kivy\properties.pyx", line 599, in kivy.properties.Property.dispatch
   File "kivy\_event.pyx", line 1248, in kivy._event.EventObservers.dispatch
   File "kivy\_event.pyx", line 1130, in kivy._event.EventObservers._dispatch
   File "C:\Users\sande\Anaconda3\lib\site-packages\kivy\lang\builder.py", line 68, in call_fn
     trace('Lang: call_fn => value=%r' % (e_value, ))
   File "C:\Users\sande\Anaconda3\lib\logging\__init__.py", line 1449, in log
     self._log(level, msg, args, **kwargs)
   File "C:\Users\sande\Anaconda3\lib\logging\__init__.py", line 1519, in _log
     self.handle(record)
   File "C:\Users\sande\Anaconda3\lib\logging\__init__.py", line 1529, in handle
     self.callHandlers(record)
   File "C:\Users\sande\Anaconda3\lib\logging\__init__.py", line 1591, in callHandlers
     hdlr.handle(record)
   File "C:\Users\sande\Anaconda3\lib\logging\__init__.py", line 905, in handle
     self.emit(record)
   File "C:\Users\sande\Anaconda3\lib\site-packages\kivy\logger.py", line 263, in emit
     self._write_message(message)
   File "C:\Users\sande\Anaconda3\lib\site-packages\kivy\logger.py", line 234, in _write_message
     stream.write(fs % msg)
@matham
Copy link
Member

matham commented Jun 1, 2020

#6910

@matham matham closed this as completed Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants