Forum Archive

appex.get_input> returned a result with an error set

djorge

I'm trying to capture text from Unread app, but appex.get_input() returns an error

#coding: utf-8
import appex

appex.get_input()

Returns:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/private/var/mobile/Containers/Shared/AppGroup/B6AB638B-3B3D-4649-85A1-8E5C6F750259/Pythonista3/Documents/Scratchpad.py", line 4, in
appex.get_input()
SystemError: returned a result with an error set

Need help please!!

Thanks in advance.

djorge

I have made some more tests and I found this only happens when there is an image in the feed item. At least, when I try to use the "Image Histogram" it shows an histogram.

I also found a weird behavior while using the scratchpad and the console with the same feed item when it has an image. In the console I am able to print the title with

print appex.get_input()[0].get('title') 
``
But if try the same code in the scratchpad with:

coding: utf-8

import appex
print(appex.get_input()[0].get('title'))

I get an exception 

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/private/var/mobile/Containers/Shared/AppGroup/B6AB638B-3B3D-4649-85A1-8E5C6F750259/Pythonista3/Documents/Scratchpad.py", line 6, in
t = appex.get_input()[0].get('title')
SystemError: returned a result with an error set
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/private/var/mobile/Containers/Shared/AppGroup/B6AB638B-3B3D-4649-85A1-8E5C6F750259/Pythonista3/Documents/Scratchpad.py", line 5, in
print(appex.get_input()[0].get('title'))
SystemError: returned a result with an error set
```
What I am doing wrong?

ccc

.encode('utf-8') or .decode('utf-8') is probably your friend...

https://wiki.python.org/moin/UnicodeDecodeError

Also piles of similar entries in StackOverflow.

omz

Are you using the App Store version or the beta? I suspect this might be a bug in the appex module that I already fixed in the beta, but I could be wrong.

djorge

@omz I'm using the Appstore version.
I was told on slack that this is already solved in beta an I have already sign-up last month but didn't receive invitation yet.