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

Android app crashing after pasting unicode string to TextInput #5096

Closed
Fogapod opened this issue Apr 3, 2017 · 7 comments
Closed

Android app crashing after pasting unicode string to TextInput #5096

Fogapod opened this issue Apr 3, 2017 · 7 comments
Assignees
Labels
Platform: Android Priority: High Should be fixed ASAP Status: Confirmed Confirmed as real issue Type: Regression Issue is a regression

Comments

@Fogapod
Copy link
Contributor

Fogapod commented Apr 3, 2017

Versions

  • Python: 2.7
  • OS: android
  • Kivy: master
  • Buildozer toolchain: android_new

Description

Kivy android app get crashed after pasting unicode string to TextInput.
This fix helped me: Fogapod@2017c66

Edit: removing .encode('utf-8') will work too

Edit: my fixes do not fix anything

Code and Logs

Traceback (most recent call last):
  File "/home/foga/Main/VKBot/.buildozer/android/app/main.py", line 19, in main
  File "/home/foga/Main/VKBot/.buildozer/android/platform/build/dists/VKBot/private/lib/python2.7/site-packages/kivy/app.py", line 828, in run
  File "/home/foga/Main/VKBot/.buildozer/android/platform/build/dists/VKBot/private/lib/python2.7/site-packages/kivy/base.py", line 504, in runTouchApp
  File "/home/foga/Main/VKBot/.buildozer/android/platform/build/dists/VKBot/private/lib/python2.7/site-packages/kivy/core/window/window_sdl2.py", line 663, in mainloop
  File "/home/foga/Main/VKBot/.buildozer/android/platform/build/dists/VKBot/private/lib/python2.7/site-packages/kivy/core/window/window_sdl2.py", line 405, in _mainloop
  File "/home/foga/Main/VKBot/.buildozer/android/platform/build/dists/VKBot/private/lib/python2.7/site-packages/kivy/base.py", line 342, in idle
  File "/home/foga/Main/VKBot/.buildozer/android/platform/build/dists/VKBot/private/lib/python2.7/site-packages/kivy/base.py", line 327, in dispatch_input
  File "/home/foga/Main/VKBot/.buildozer/android/platform/build/dists/VKBot/private/lib/python2.7/site-packages/kivy/base.py", line 233, in post_dispatch_input
  File "kivy/_event.pyx", line 718, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:7336)
  File "/home/foga/Main/VKBot/.buildozer/android/platform/build/dists/VKBot/private/lib/python2.7/site-packages/kivy/core/window/__init__.py", line 1192, in on_motion
  File "kivy/_event.pyx", line 718, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:7336)
  File "/home/foga/Main/VKBot/.buildozer/android/platform/build/dists/VKBot/private/lib/python2.7/site-packages/kivy/core/window/__init__.py", line 1228, in on_touch_up
  File "kivy/_event.pyx", line 718, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:7336)
  File "/home/foga/Main/VKBot/.buildozer/android/platform/build/dists/VKBot/private/lib/python2.7/site-packages/kivy/uix/textinput.py", line 328, in on_touch_up
  File "/home/foga/Main/VKBot/.buildozer/android/platform/build/dists/VKBot/private/lib/python2.7/site-packages/kivy/uix/widget.py", line 479, in on_touch_up
  File "kivy/_event.pyx", line 718, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:7336)
  File "/home/foga/Main/VKBot/.buildozer/android/platform/build/dists/VKBot/private/lib/python2.7/site-packages/kivy/uix/widget.py", line 479, in on_touch_up
  File "kivy/_event.pyx", line 718, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:7336)
  File "/home/foga/Main/VKBot/.buildozer/android/platform/build/dists/VKBot/private/lib/python2.7/site-packages/kivy/uix/behaviors/button.py", line 179, in on_touch_up
  File "kivy/_event.pyx", line 714, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:7295)
  File "kivy/_event.pyx", line 1225, in kivy._event.EventObservers.dispatch (kivy/_event.c:12844)
  File "kivy/_event.pyx", line 1109, in kivy._event.EventObservers._dispatch (kivy/_event.c:11810)
  File "/home/foga/Main/VKBot/.buildozer/android/platform/build/dists/VKBot/private/lib/python2.7/site-packages/kivy/lang/builder.py", line 64, in custom_callback
  File "/data/user/0/org.vkbot/files/app/lib/python2.7/site-packages/kivy/data/style.kv", line 213, in <module>
    on_release: root.do('paste')
  File "/home/foga/Main/VKBot/.buildozer/android/platform/build/dists/VKBot/private/lib/python2.7/site-packages/kivy/uix/textinput.py", line 380, in do
  File "/home/foga/Main/VKBot/.buildozer/android/platform/build/dists/VKBot/private/lib/python2.7/site-packages/kivy/uix/textinput.py", line 1723, in paste
  File "/home/foga/Main/VKBot/.buildozer/android/platform/build/dists/VKBot/private/lib/python2.7/site-packages/kivy/core/clipboard/__init__.py", line 81, in paste
  File "/home/foga/Main/VKBot/.buildozer/android/platform/build/dists/VKBot/private/lib/python2.7/site-packages/kivy/core/clipboard/__init__.py", line 97, in _paste
  File "/home/foga/Main/VKBot/.buildozer/android/platform/build/dists/VKBot/private/lib/python2.7/site-packages/kivy/core/clipboard/clipboard_android.py", line 34, in get
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)
@KeyWeeUsr
Copy link
Contributor

Repasting if something would happen to that commit:

diff --git a/kivy/core/clipboard/clipboard_android.py b/kivy/core/clipboard/clipboard_android.py
index 426a4ca..85e3cad 100644
--- a/kivy/core/clipboard/clipboard_android.py
+++ b/kivy/core/clipboard/clipboard_android.py
@@ -31,7 +31,7 @@ def __init__(self):
         PythonActivity._clipboard = None
 
     def get(self, mimetype='text/plain'):
-        return self._get(mimetype).encode('utf-8')
+        return self._get(mimetype).decode('utf8').encode('utf-8')
 
     def put(self, data, mimetype='text/plain'):
         self._set(data, mimetype)

@Fogapod
Copy link
Contributor Author

Fogapod commented May 12, 2017

Same problem on old toolchain

@Fogapod
Copy link
Contributor Author

Fogapod commented Jun 17, 2017

Also unicode text gets corrupted after copying it. Version: 1.10.0

Text in TextInput:
Привет 123
Text in clipboard after copying:
��ве� 123

@Fogapod
Copy link
Contributor Author

Fogapod commented Jul 22, 2017

#2418

@KeyWeeUsr KeyWeeUsr added Status: Confirmed Confirmed as real issue Priority: High Should be fixed ASAP Platform: Android Type: Regression Issue is a regression labels Jul 22, 2017
@Fogapod
Copy link
Contributor Author

Fogapod commented Aug 29, 2017

#5023

@Fogapod
Copy link
Contributor Author

Fogapod commented Aug 29, 2017

#3606

@akshayaurora akshayaurora self-assigned this Aug 29, 2017
@tshirtman
Copy link
Member

I can copy/paste unicode text in recent kivy apps, i assume this is fixed, at least for python3, closing, feel free to reopen or open a new one if similar bugs are observed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Android Priority: High Should be fixed ASAP Status: Confirmed Confirmed as real issue Type: Regression Issue is a regression
Projects
None yet
Development

No branches or pull requests

4 participants