-
-
Notifications
You must be signed in to change notification settings - Fork 263
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
Fixes for Python 3 migration #211
Conversation
This comment has been minimized.
This comment has been minimized.
I had to make the corrections you didn't make |
commits are temporary |
you said you didn't want responsibility to break the addon so i thought I'd do it this way... |
This comment has been minimized.
This comment has been minimized.
so wait, I'll try to join |
This comment has been minimized.
This comment has been minimized.
You know what, I'll close my PR. Since you already have been adding more commits to this PR it is probably going to be a lot easier. |
I was doing the pull on your branch ... that's why it went in error... ok as you prefer |
how do run integrity tests under windows? |
Look in the Makefile for the right commands. In Linux you can just do |
BTW I still need to add routing integration tests, but I added the |
I'd like to make a release, do you think it's better to wait and include this PR or can i proceed? |
I have to check for MySQL again with some specific use cases if you don't mind, but I think I can do it before the evening. |
As long as everything has been tested on Python 2.7 I think we're good. I haven't seen any issues (run-time or visual defects) on Python 2.7 with my PR during end-to-end testing. But we currently do not test all code-paths as we should so there's no real guarantee. (And there wasn't a guarantee before either ;-)) |
I only did a quick test with mysql...a more thorough one is appreciated |
@CastagnaIT I wasn't talking about MySQL specifically, there is a lot more code-paths we don't cover (see coverage results). And we don't have proper tests for most of the input/output functionality in Kodi/python to know for sure that we handle everything correctly wrt. unicode. I am struggling with this for other add-ons as well, but it shouldn't be worse than before we added tests ;-) Update: We don't have coverage reports at the moment because we do not run any of these tests yet. (See .travis) https://codecov.io/gh/dagwieers/plugin.video.netflix/branch/preparation |
resources/lib/common/kodiops.py
Outdated
@@ -37,7 +40,7 @@ def json_rpc(method, params=None): | |||
'params': params or {}} | |||
request = json.dumps(request_data) | |||
debug('Executing JSON-RPC: {}'.format(request)) | |||
raw_response = unicode(xbmc.executeJSONRPC(request), 'utf-8') | |||
raw_response = text(xbmc.executeJSONRPC(request)).encode('utf-8') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the series "3%" exported, I can't start an episode. I always get a UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1013: ordinal not in range(128). This is not related to any accentuated chars, it does the same with series with no accent or anything special in the name of the series or the episode.
I don't know how to fix it, and I fear all text() functions are suffering the issue :/
See here for the first error in json_rpc() https://paste.kodi.tv/vitenogebu.kodi
And here for the same kind of error in _decrypt_chunks() https://paste.kodi.tv/olinafikon.kodi
Till this error exists, I can't go further. I'm sorry I can't help more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Smeulf You have an actual Kodi with Python 3 support that works?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it's Python 2 (Kodi 18.2, "prod" Raspberry Pi)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But that's not the exact same code you proposed in your PR, yours was raw_response = text(xbmc.executeJSONRPC(request), 'utf-8')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes is not same becouse the text(xbmc.executeJSONRPC(request), 'utf-8')
do not work with py2, str do not have parameters...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it worked, i hate UnicodeDecodeError is a ugly beast
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not work with py2, str do not have parameters...
'str' or 'text' ? @dagwieers was using 'text'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works fine on Python 2:
from builtins import str as text
print("%r" % text(u"wieërs", "utf-8"))
Returns 'wie\xc3\xabrs'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
text is only a reference to str (in py2) look to the imports
Using def to_unicode(text, encoding='utf-8'):
''' Force text to unicode '''
return text.decode(encoding) if isinstance(text, bytes) else text
def from_unicode(text, encoding='utf-8'):
''' Force unicode to text '''
import sys
if sys.version_info.major == 2 and isinstance(text, unicode): # noqa: F821; pylint: disable=undefined-variable
return text.encode(encoding)
return text I was planning to implement this, before my branch was hijacked ;-) |
I want to try again but tonight i can't |
ceb5848
to
9d063d1
Compare
now it should work, |
This fixes the known Python 3 issues reported by kodi-addon-checker. Also includes various known fixes for Python 3 Co-authored-by: Stefano Gottardo <[email protected]>
now the installation is done correctly
I plan the merge to master in one/two days |
Something does not work this version - at first a problem with Polish characters (ś), then addonsignals timeout The stable version obviously works. |
Can you try this? |
This version works |
Check if this PR fulfills these requirements:
Types of changes
Description
Porting of the PR #198
Fixes for migration to python 3, this include also fixes to allow execution with the both versions of Python:
Kodi 18.x >> Python 2
Kodi 19.x >> Python 3
Tests:
All tests are performed with a spanish profile in order to test unicode special chars cases
in follow devices:
Kodi 19.x on LibreELEC (at now the only build ready with Py3 and reuselanguageinvoker)
Kodi 18.x on Windows
List of tests:
✔Addon start
✔Cache
✔Cookies
✔Loading lists
✔Play videos
✔Library (export/remove/update context menu)
✔Auto-update all settings features
✔NFO files
✔Shared library MySQL
✔In general test all settings options
✔UpNext integration
...Other?
Who wants to give a concrete help means to verify continuously the output of the logs for every operation carried out so not only what you see on screen
In case of Feature change / Breaking change:
Describe the current behavior
Describe the new behavior
Screenshots (if appropriate):